File-DataClass
view release on metacpan or search on metacpan
lib/File/DataClass/Storage.pm view on Meta::CPAN
}
# Backcompat
sub _read_file {
throw 'Class [_1] should never call _read_file', [ blessed $_[ 0 ] ];
}
sub _write_file {
throw 'Class [_1] should never call _write_file', [ blessed $_[ 0 ] ];
}
1;
__END__
=pod
=head1 Name
File::DataClass::Storage - Storage base class
=head1 Synopsis
=head1 Description
Storage base class
=head1 Configuration and Environment
Defines the following attributes;
=over 3
=item C<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
=item C<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
=item C<encoding>
Used by subclasses to encode/decode the file data on ouput/input. Defaults
to the null string
=item C<extn>
The filename extension for this type of file. Usually overridden in the
subclass. Default to the null string
=item C<read_options>
This hash reference is used to customise the decoder object used when
reading the file. It defaults to an empty reference
=item C<schema>
A weakened schema object reference
=item C<write_options>
This hash reference is used to customise the encoder object used when
writing the file. It defaults to an empty reference
=back
=head1 Subroutines/Methods
=head2 create_or_update
$bool = $self->create_or_update( $path, $result, $updating, $condition );
Does the heavy lifting for L</insert> and L</update>. The C<$updating> boolean
is true for updating false otherwise. The C<$condition> code reference is
used to filter updates
=head2 delete
$bool = $storage->delete( $path, $result );
Deletes the specified result object returning true if successful. Throws
an error otherwise. Path is an instance of L<File::DataClass::IO>. The
result is an instance of L<File::DataClass::Result>
=head2 DEMOLISH
Called during object destruction it deletes any outstanding locks
=head2 dump
$data = $storage->dump( $path, $data );
Dumps the data to the specified path. Path is an instance of
L<File::DataClass::IO>
=head2 insert
$bool = $storage->insert( $path, $result );
Inserts the specified result object returning true if successful. Throws
an error otherwise. Path is an instance of L<File::DataClass::IO>. The
result is an instance of L<File::DataClass::Result>
=head2 load
$hash_ref = $storage->load( @paths );
Loads each of the specified files merging the resultant hash ref which
it returns. Paths are instances of L<File::DataClass::IO>
=head2 meta_pack
Converts from scalar to hash reference. The scalar is the modification time
of the file
=head2 meta_unpack
Converts from hash reference to scalar. The scalar is the modification time
( run in 1.643 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )