File-Gettext
view release on metacpan or search on metacpan
lib/File/Gettext/Storage.pm view on Meta::CPAN
$data = {}; $newest = 0;
for my $path (@paths) {
my ($red, $path_mtime) = $self->read_file( $path, FALSE );
merge_file_data $data, $red;
$path_mtime > $newest and $newest = $path_mtime;
$path_mtime = $self->$_load_gettext( $data, $path );
$path_mtime and $path_mtime > $newest and $newest = $path_mtime;
}
$self->cache->set( $key, $data, $self->meta_pack( $newest ) );
return $data;
}
sub select {
my ($self, $path, $element) = @_; $self->validate_params( $path, $element );
my $data = $self->load( $path );
return exists $data->{ $element } ? $data->{ $element } : {};
}
sub update {
return $_[ 0 ]->$_create_or_update( $_[ 1 ], $_[ 2 ], TRUE );
}
1;
__END__
=pod
=encoding utf-8
=head1 Name
File::Gettext::Storage - Split/merge language dependent data
=head1 Synopsis
=head1 Description
This is a proxy for the storage class. In general, for each call made to a
storage method this class makes two instead. The "second" call handles
attributes stored in the language dependent file
=head1 Configuration and Environment
Defines the attributes
=over 3
=item C<lang>
Two character language code
=item C<schema>
A weakened reference to the schema object
=item C<storage>
Instance of L<File::DataClass::Storage>
=back
=head1 Subroutines/Methods
=head2 delete
$bool = $self->delete( $path, $result );
Deletes the specified element object returning true if successful. Throws
an error otherwise
=head2 dump
$data = $self->dump( $path, $data );
Exposes L<File::DataClass::Storage/dump> in the storage class
=head2 insert
$bool = $self->insert( $path, $result );
Inserts the specified element object returning true if successful. Throws
an error otherwise
=head2 load
$data = $self->load( $path );
Exposes L<File::DataClass::Storage/load> in the storage class
=head2 select
$hash_ref = $self->select( $element );
Returns a hash ref containing all the elements of the type specified in the
result source
=head2 update
$bool = $self->update( $path, $result );
Updates the specified element object returning true if successful. Throws
an error otherwise
=head1 Diagnostics
None
=head1 Dependencies
=over 3
=item L<File::Gettext>
=back
( run in 0.526 second using v1.01-cache-2.11-cpan-39bf76dae61 )