Scalar-Accessors-LikeHash

 view release on metacpan or  search on metacpan

lib/Tie/Hash/SerializedString.pm  view on Meta::CPAN

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use Carp;
 
sub TIEHASH
{
        my $class = shift;
        my ($ref, $implementation) = @_;
        croak "need a scalar ref to tie hash to" unless ref $ref eq 'SCALAR';
        $implementation = "Scalar::Accessors::LikeHash::JSON" unless defined $implementation;
        Module::Runtime::use_package_optimistically($implementation);
        bless [$implementation, $ref] => $class;
}
 
for my $method (qw( STORE FETCH EXISTS DELETE CLEAR ))
{
        my $lc_method = lc $method;
        my $coderef = sub {
                my ($implementation, $ref) = @{+shift};
                return $implementation->$lc_method($ref, @_);
        };
        no strict 'refs';



( run in 0.254 second using v1.01-cache-2.11-cpan-94b05bcf43c )