sub
make_encode_sub {
my
(
$class
,
$col
,
$args
) =
@_
;
my
$gen_salt_meth
=
$args
->{
'salt'
};
die
"Valid 'salt' is a coderef which returns the salt string."
unless
ref
$gen_salt_meth
eq
'CODE'
;
return
sub
{
my
(
$plain_text
,
$salt
) =
@_
;
$salt
||=
$gen_salt_meth
->();
return
crypt
(
$plain_text
,
$salt
);
};
}
sub
make_check_sub {
my
(
$class
,
$col
,
$args
) =
@_
;
return
eval
qq^ sub {
my \$col_v = \$_[0]->get_column('${col}');
\$_[0]->_column_encoders->{${col}}->(\$_[1], \$col_v) eq \$col_v;
} ^
||
die
($@);
}
1;