File::DataClass::Schema - Base class for schema definitions
use File::DataClass::Schema; $schema = File::DataClass::Schema->new ( path => [ qw( path to a file ) ], result_source_attributes => { source_name => {}, }, tempdir => [ qw( path to a directory ) ] ); $schema->source( q(source_name) ) ->attributes( [ qw( list of attr names ) ] ); $rs = $schema->resultset( 'source_name' ); $result = $rs->find( { name => 'id of field element to find' } ); $result->$attr_name( $some_new_value ); $result->update; @result = $rs->search( { 'attr name' => 'some value' } );
Base class for schema definitions. Each record in a data file requires a result source to define it's attributes
Registers all result sources defined by the result source attributes
Creates a new instance of the storage class which defaults to File::DataClass::Storage::JSON
Defines these attributes
cache
Instantiates and returns the Cache class attribute. Built on demand
cache_attributes
Passed to the Cache::Cache constructor
cache_class
Classname used to create the cache object. Defaults to File::DataClass::Cache
lock
Defaults to Class::Null. Can be set via the builder attribute. Built on demand
builder
log
Log object. Typically an instance of Log::Handler
path
Path to the file. This is a File::DataClass::IO object that can be coerced from either a string or an array ref
perms
Permissions to set on the file if it is created. Defaults to PERMS
result_source_attributes
A hash ref of result sources. See File::DataClass::ResultSource
result_source_class
The class name used to create result sources when the source registration attribute is instantiated. Acts as a schema wide default of not overridden in the result_source_attributes
source_registrations
A hash ref or registered result sources, i.e. the keys of the result_source_attributes hash
storage
An instance of a subclass of File::DataClass::Storage
storage_attributes
Attributes passed to the storage object's constructor
storage_base
If the storage class is only a partial classname then this attribute is prepended to it
storage_class
The name of the storage class to instantiate
tempdir
Temporary directory used to store the cache and lock objects disk representation
Constructs the attribute hash passed to the constructor method
$schema->dump( { path => $to_file, data => $data_hash } );
Dumps the data structure to a file. Path defaults to the one specified in the schema definition. Returns the data that was written to the file if successful. Can be called a class or an object method
\%extension_map = $self->extensions;
DEPRECATED: Use the function extension2class instead
extension2class
Returns a hash ref that maps filename extensions (keys) onto storage subclasses (values)
$data_hash = $schema->load( @paths );
Loads and returns the merged data structure from the named files. Paths defaults to the one specified in the schema definition. Data will be read from cache if available and not stale. Can be called a class or an object method
$rs = $schema->resultset( $source_name );
Returns a resultset object which by default is an instance of File::DataClass::Resultset
$source = $schema->source( $source_name );
Returns a result source object which by default is an instance of File::DataClass::ResultSource
@sources = $schema->sources;
Returns a list of all registered result source names
$schema->translate( $args );
Reads a file in one format and writes it back out in another format
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
Larry Wall - For the Perl programming language
Peter Flanigan, <pjfl@cpan.org>
<pjfl@cpan.org>
Copyright (c) 2015 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.