Name

Class::Usul::File - Data loading and dumping

Synopsis

package YourClass;

use Class::Usul::File;

my $file_obj = Class::Usul::File->new( builder => Class::Usul->new );

Description

Provides data loading and dumping methods, Also temporary file methods and directories instantiated using the Class::Usul::Config object

Configuration and Environment

Defined the following attributes;

config

A required instance of type ConfigProvider

lock

A required instance of type Locker

log

A required instance of type Logger

Subroutines/Methods

BUILDARGS

Extracts the required constructor attributes from the builder attribute if it was supplied

data_dump

$self->dump( @args );

Accepts either a list or a hash ref. Calls "dataclass_schema" with the storage_class attribute if supplied. Calls the dump method

data_load

$hash_ref = $self->load( @args );

Accepts either a list or a hash ref. Calls "dataclass_schema" with the storage_class and arrays attributes if supplied. Calls the load method

dataclass_schema

$f_dc_schema_obj = $self->dataclass_schema( $attrs );

Returns a File::DataClass::Schema object. Object uses our exception_class, no caching and no locking by default. Works as a class method

delete_tmp_files

$self->delete_tmp_files( $dir );

Delete this processes temporary files. Files are in the $dir directory which defaults to $self->tempdir

tempdir

$temporary_directory = $self->tempdir;

Returns $self->config->tempdir or "tmpdir" in File::Spec

tempfile

$tempfile_obj = $self->tempfile( $dir );

Returns a File::Temp object in the $dir directory which defaults to $self->tempdir. File is automatically deleted if the $tempfile_obj reference goes out of scope

tempname

$pathname = $self->tempname( $dir );

Returns the pathname of a temporary file in the given directory which defaults to $self->tempdir. The file will be deleted by "delete_tmp_files" if it is called otherwise it will persist

Diagnostics

None

Dependencies

Class::Usul::Constants
File::DataClass::IO
File::Temp

Incompatibilities

There are no known incompatibilities in this module

Bugs and Limitations

There are no known bugs in this module. Please report problems to the address below. Patches are welcome

Author

Peter Flanigan, <pjfl@cpan.org>

License and Copyright

Copyright (c) 2018 Peter Flanigan. All rights reserved

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic

This program is distributed in the hope that it will be useful, but WITHOUT WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE