Scalar-Accessors-LikeHash
view release on metacpan or search on metacpan
lib/Tie/Hash/SerializedString.pm view on Meta::CPAN
111213141516171819202122232425262728293031use
Carp;
use
Module::Runtime;
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 )