File::DataClass::Storage - Storage base class
Storage base class
Defines the following attributes;
atomic_write
Hash reference containing the keys of any locks set by the storage object. Used during object destruction to free any left over locks
backup
Extension appended to the file name. Used to create a backup of the updated file. Defaults to the null string so no backup created
encoding
Used by subclasses to encode/decode the file data on ouput/input. Defaults to the null string
extn
The filename extension for this type of file. Usually overridden in the subclass. Default to the null string
read_options
This hash reference is used to customise the decoder object used when reading the file. It defaults to an empty reference
schema
A weakened schema object reference
write_options
This hash reference is used to customise the encoder object used when writing the file. It defaults to an empty reference
$bool = $self->create_or_update( $path, $result, $updating, $condition );
Does the heavy lifting for "insert" and "update". The $updating boolean is true for updating false otherwise. The $condition code reference is used to filter updates
$updating
$condition
$bool = $storage->delete( $path, $result );
Deletes the specified result object returning true if successful. Throws an error otherwise. Path is an instance of File::DataClass::IO. The result is an instance of File::DataClass::Result
Called during object destruction it deletes any outstanding locks
$data = $storage->dump( $path, $data );
Dumps the data to the specified path. Path is an instance of File::DataClass::IO
$bool = $storage->insert( $path, $result );
Inserts the specified result object returning true if successful. Throws an error otherwise. Path is an instance of File::DataClass::IO. The result is an instance of File::DataClass::Result
$hash_ref = $storage->load( @paths );
Loads each of the specified files merging the resultant hash ref which it returns. Paths are instances of File::DataClass::IO
Converts from scalar to hash reference. The scalar is the modification time of the file
Converts from hash reference to scalar. The scalar is the modification time of the file
($data, $mtime) = $self->read_file( $path, $for_update ):
Read a file from cache or disk
$data = $self->read_from_file( $io_object_ref );
Should be overridden in the subclass
$hash_ref = $storage->select( $path );
Returns a hash reference containing all the records for the result source specified in the schema. Path is an instance of File::DataClass::IO
Executes the supplied coderef wrapped in lock on the pathname
$bool = $storage->update( $path, $result, $updating, $condition );
Updates the specified result object returning true if successful. Throws an error otherwise. Path is an instance of File::DataClass::IO. The result is an instance of File::DataClass::Result
$storage->validate_params( $path, $rsrc_name );
Throw if $path or $rsrc_name are not specified or $path is not blessed
$path
$rsrc_name
$data = $self->write_file( $path, $data, $create );
Writes $data to $path. Will throw if $create is not true and $path does not exist
$data
$create
$data = $self->write_to_file( $io_object_ref, $data );
None
There are no known incompatibilities in this module
There are no known bugs in this module. Please report problems to the address below. Patches are welcome
Peter Flanigan, <pjfl@cpan.org>
<pjfl@cpan.org>
Copyright (c) 2016 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
To install File::DataClass, copy and paste the appropriate command in to your terminal.
cpanm
cpanm File::DataClass
CPAN shell
perl -MCPAN -e shell install File::DataClass
For more information on module installation, please visit the detailed CPAN module installation guide.