File-DataClass
view release on metacpan or search on metacpan
lib/File/DataClass/Cache.pm view on Meta::CPAN
use File::DataClass::Types qw( Bool Cache ClassName HashRef
LoadableClass Object Str );
use Storable qw( freeze );
use Try::Tiny;
use Moo;
# Public attributes
has 'cache' => is => 'lazy', isa => Object, builder => sub {
$_[ 0 ]->cache_class->new( %{ $_[ 0 ]->cache_attributes } ) };
has 'cache_attributes' => is => 'ro', isa => HashRef, required => TRUE;
has 'cache_class' => is => 'lazy', isa => LoadableClass,
default => 'Cache::FastMmap';
has 'log' => is => 'ro', isa => Object, required => TRUE;
# Private attributes
has '_mtimes_key' => is => 'ro', isa => Str, default => '_mtimes';
# Construction
lib/File/DataClass/Cache.pm view on Meta::CPAN
=head1 Synopsis
package File::DataClass::Schema;
use Moo;
use File::DataClass::Types qw(Cache);
use File::DataClass::Cache;
has 'cache' => is => 'lazy', isa => Cache;
has 'cache_attributes' => is => 'ro', isa => 'HashRef',
default => sub { return {} };
my $_cache_objects = {};
sub _build_cache {
my $self = shift; (my $ns = lc __PACKAGE__) =~ s{ :: }{-}gmx; my $cache;
my $attrs = { cache_attributes => { %{ $self->cache_attributes } },
builder => $self };
lib/File/DataClass/IO.pm view on Meta::CPAN
has '_assert' => is => 'rw', isa => Bool, default => FALSE ;
has '_atomic' => is => 'rw', isa => Bool, default => FALSE ;
has '_atomic_infix' => is => 'rw', isa => SimpleStr, default => 'B_*' ;
has '_backwards' => is => 'rw', isa => Bool, default => FALSE ;
has '_block_size' => is => 'rw', isa => PositiveInt, default => 1024 ;
has '_chomp' => is => 'rw', isa => Bool, default => FALSE ;
has '_deep' => is => 'rw', isa => Bool, default => FALSE ;
has '_dir_pattern' => is => 'lazy', isa => RegexpRef,
builder => $_build_dir_pattern ;
has '_filter' => is => 'rw', isa => Maybe[CodeRef] ;
has '_layers' => is => 'ro', isa => ArrayRef[SimpleStr],
builder => sub { [] } ;
has '_lock' => is => 'rw', isa => $IO_LOCK, default => FALSE ;
has '_no_follow' => is => 'rw', isa => Bool, default => FALSE ;
has '_separator' => is => 'rw', isa => Str, default => $RS ;
has '_umask' => is => 'ro', isa => ArrayRef[Int],
builder => sub { [] } ;
# Construction
my @ARG_NAMES = qw( name mode perms );
my $_clone_one_of_us = sub {
my ($self, $params) = @_;
$self->autoclose; $self->reverse; $self->sort; # Force evaluation
lib/File/DataClass/List.pm view on Meta::CPAN
package File::DataClass::List;
use namespace::autoclean;
use Moo;
use File::DataClass::Types qw( ArrayRef Bool HashRef Result Undef );
has 'found' => is => 'ro', isa => Bool, default => 0;
has 'labels' => is => 'ro', isa => HashRef, builder => sub { {} };
has 'list' => is => 'ro', isa => ArrayRef, builder => sub { [] };
has 'result' => is => 'ro', isa => Result | Undef;
1;
__END__
=pod
=head1 Name
lib/File/DataClass/ResultSource.pm view on Meta::CPAN
# Private functions
my $_build_attributes = sub {
my $self = shift; my $attr = {};
$attr->{ $_ } = TRUE for (@{ $self->attributes });
return $attr;
};
# Public attributes
has 'attributes' => is => 'ro', isa => ArrayRef[Str],
required => TRUE;
has 'defaults' => is => 'ro', isa => HashRef, builder => sub { {} };
has 'name' => is => 'ro', isa => SimpleStr, required => TRUE;
has 'label_attr' => is => 'ro', isa => SimpleStr, default => NUL;
has 'resultset_attributes' => is => 'ro', isa => HashRef, builder => sub { {} };
has 'resultset_class' => is => 'ro', isa => ClassName,
default => 'File::DataClass::ResultSet';
has 'schema' => is => 'ro', isa => Object,
handles => [ 'path', 'storage' ],
required => TRUE, weak_ref => TRUE;
has 'types' => is => 'ro', isa => HashRef, builder => sub { {} };
has '_attributes' => is => 'lazy', isa => HashRef,
builder => $_build_attributes, init_arg => undef;
# Public methods
sub columns {
return @{ $_[ 0 ]->attributes };
}
sub has_column {
lib/File/DataClass/Schema.pm view on Meta::CPAN
my $class = shift;
my $attr = { cache_class => 'none', storage_class => 'Any' };
return $class->new( $attr );
};
# Private attributes
has 'cache' => is => 'lazy', isa => Cache,
builder => $_build_cache;
has 'cache_attributes' => is => 'ro', isa => HashRef,
builder => sub { {
page_size => 131_072,
num_pages => 89,
unlink_on_exit => TRUE, } };
has 'cache_class' => is => 'ro', isa => ClassName | DummyClass,
default => 'File::DataClass::Cache';
has 'lock' => is => 'lazy', isa => Lock,
builder => sub { Class::Null->new };
has 'log' => is => 'lazy', isa => Object,
builder => sub { Class::Null->new };
has 'path' => is => 'rw', isa => Path, coerce => TRUE;
has 'perms' => is => 'rw', isa => Num, default => PERMS;
has 'result_source_attributes' => is => 'ro', isa => HashRef,
builder => sub { {} };
has 'result_source_class' => is => 'ro', isa => ClassName,
default => 'File::DataClass::ResultSource';
has 'source_registrations' => is => 'lazy', isa => HashRef[Object],
builder => $_build_source_registrations;
has 'storage' => is => 'rw', isa => Object,
builder => $_build_storage, lazy => TRUE;
has 'storage_attributes' => is => 'ro', isa => HashRef,
builder => sub { {} };
has 'storage_class' => is => 'rw', isa => Str,
default => 'JSON', lazy => TRUE;
has 'tempdir' => is => 'ro', isa => Directory,
coerce => TRUE, builder => sub { File::Spec->tmpdir };
# Construction
around 'BUILDARGS' => sub {
lib/File/DataClass/Storage.pm view on Meta::CPAN
use Moo;
has 'atomic_write' => is => 'ro', isa => Bool, default => TRUE;
has 'backup' => is => 'ro', isa => Str, default => NUL;
has 'encoding' => is => 'ro', isa => Str, default => NUL;
has 'extn' => is => 'ro', isa => Str, default => NUL;
has 'read_options' => is => 'ro', isa => HashRef, builder => sub { {} };
has 'schema' => is => 'ro', isa => Object,
handles => { _cache => 'cache', _lock => 'lock',
_log => 'log', _perms => 'perms', },
required => TRUE, weak_ref => TRUE;
has 'write_options' => is => 'ro', isa => HashRef, builder => sub { {} };
has '_locks' => is => 'ro', isa => HashRef, builder => sub { {} };
# Private functions
my $_get_src_attributes = sub {
my ($cond, $src) = @_;
return grep { not m{ \A _ }mx
and $_ ne 'id' and $_ ne 'name'
and $cond->( $_ ) } keys %{ $src };
};
lib/File/DataClass/Storage/Any.pm view on Meta::CPAN
is_stale merge_file_data throw );
use File::DataClass::Storage;
use File::DataClass::Types qw( Object HashRef );
use Moo;
has 'schema' => is => 'ro', isa => Object,
handles => [ 'cache', 'storage_attributes', ],
required => TRUE, weak_ref => TRUE;
has '_stores' => is => 'ro', isa => HashRef, default => sub { {} };
# Private methods
my $_get_store_from_extension = sub {
my ($self, $extn) = @_; my $stores = $self->_stores;
exists $stores->{ $extn } and return $stores->{ $extn };
my $list; ($list = map_extension2class( $extn ) and my $class = $list->[ 0 ])
or throw 'Extension [_1] has no class', [ $extn ];
( run in 0.871 second using v1.01-cache-2.11-cpan-5f2e87ce722 )