View on
MetaCPAN
search.cpan.org is shutting down
For details read Perl NOC. After June 25th this page will redirect to MetaCPAN.org
Peter Flanigan > File-DataClass > File::DataClass::Storage

Download:
file-dataclass/File-DataClass-0.73.1.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

Open  0
View/Report Bugs
Module Version: v0.73.1   Source  

Name ^

File::DataClass::Storage - Storage base class

Synopsis ^

Description ^

Storage base class

Configuration and Environment ^

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

Subroutines/Methods ^

create_or_update

   $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

delete

   $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

DEMOLISH

Called during object destruction it deletes any outstanding locks

dump

   $data = $storage->dump( $path, $data );

Dumps the data to the specified path. Path is an instance of File::DataClass::IO

insert

   $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

load

   $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

meta_pack

Converts from scalar to hash reference. The scalar is the modification time of the file

meta_unpack

Converts from hash reference to scalar. The scalar is the modification time of the file

read_file

   ($data, $mtime) = $self->read_file( $path, $for_update ):

Read a file from cache or disk

read_from_file

   $data = $self->read_from_file( $io_object_ref );

Should be overridden in the subclass

select

   $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

txn_do

Executes the supplied coderef wrapped in lock on the pathname

update

   $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

validate_params

   $storage->validate_params( $path, $rsrc_name );

Throw if $path or $rsrc_name are not specified or $path is not blessed

write_file

   $data = $self->write_file( $path, $data, $create );

Writes $data to $path. Will throw if $create is not true and $path does not exist

write_to_file

   $data = $self->write_to_file( $io_object_ref, $data );

Should be overridden in the subclass

Diagnostics ^

None

Dependencies ^

Unexpected

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) 2017 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

syntax highlighting: