File Coverage

blib/lib/DBIx/Class/EncodedColumn/Crypt.pm
Criterion Covered Total %
statement 15 15 100.0
branch 2 2 100.0
condition 3 5 60.0
subroutine 5 5 100.0
pod 0 2 0.0
total 25 29 86.2


line stmt bran cond sub pod time code
1             package DBIx::Class::EncodedColumn::Crypt;
2              
3 1     1   18363 use strict;
  1         2  
  1         30  
4 1     1   3 use warnings;
  1         2  
  1         150  
5              
6             our $VERSION = '0.01';
7              
8             sub make_encode_sub {
9 2     2 0 887 my ($class, $col, $args) = @_;
10 2         4 my $gen_salt_meth = $args->{'salt'};
11 2 100       14 die "Valid 'salt' is a coderef which returns the salt string."
12             unless ref $gen_salt_meth eq 'CODE';
13              
14             return sub {
15 3     3   10 my ($plain_text, $salt) = @_;
16 3   66     9 $salt ||= $gen_salt_meth->();
17 3         123 return crypt($plain_text, $salt);
18 1         6 };
19             }
20              
21             sub make_check_sub {
22 1     1 0 4 my($class, $col, $args) = @_;
23             #fast fast fast
24 1   50     94 return eval qq^ sub {
25             my \$col_v = \$_[0]->get_column('${col}');
26             \$_[0]->_column_encoders->{${col}}->(\$_[1], \$col_v) eq \$col_v;
27             } ^ || die($@);
28             }
29              
30             1;
31              
32             __END__;