line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
2
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
3
|
|
|
|
|
|
|
package Data::Rx::Type::Perl::Ref; |
4
|
|
|
|
|
|
|
{ |
5
|
|
|
|
|
|
|
$Data::Rx::Type::Perl::Ref::VERSION = '0.009'; |
6
|
|
|
|
|
|
|
} |
7
|
|
|
|
|
|
|
# ABSTRACT: experimental / perl reference type |
8
|
1
|
|
|
1
|
|
3
|
use parent 'Data::Rx::CommonType::EasyNew'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
52
|
use Carp (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
15
|
|
12
|
1
|
|
|
1
|
|
4
|
use Scalar::Util (); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
287
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
0
|
23
|
sub type_uri { 'tag:codesimply.com,2008:rx/perl/ref' } |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub guts_from_arg { |
17
|
3
|
|
|
3
|
0
|
1793
|
my ($class, $arg, $rx) = @_; |
18
|
3
|
|
50
|
|
|
11
|
$arg ||= {}; |
19
|
|
|
|
|
|
|
|
20
|
3
|
|
|
|
|
7
|
for my $key (keys %$arg) { |
21
|
3
|
50
|
|
|
|
9
|
next if $key eq 'referent'; |
22
|
0
|
|
|
|
|
0
|
Carp::croak( |
23
|
|
|
|
|
|
|
"unknown argument $key in constructing " . $class->type_uri . " type", |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
3
|
|
|
|
|
6
|
my $guts = { }; |
28
|
|
|
|
|
|
|
|
29
|
3
|
50
|
|
|
|
7
|
if ($arg->{referent}) { |
30
|
3
|
|
|
|
|
19
|
my $ref_checker = $rx->make_schema($arg->{referent}); |
31
|
|
|
|
|
|
|
|
32
|
3
|
|
|
|
|
132
|
$guts->{referent} = $ref_checker; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
3
|
|
|
|
|
6
|
return $guts; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub assert_valid { |
39
|
11
|
|
|
11
|
0
|
2281
|
my ($self, $value) = @_; |
40
|
|
|
|
|
|
|
|
41
|
11
|
100
|
100
|
|
|
81
|
unless (ref $value and (ref $value eq 'REF' or ref $value eq 'SCALAR')) { |
|
|
|
66
|
|
|
|
|
42
|
3
|
|
|
|
|
24
|
$self->fail({ |
43
|
|
|
|
|
|
|
error => [ qw(type) ], |
44
|
|
|
|
|
|
|
message => "found value is not a scalar reference", |
45
|
|
|
|
|
|
|
value => $value, |
46
|
|
|
|
|
|
|
}); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
8
|
50
|
|
|
|
30
|
if ($self->{referent}) { |
50
|
|
|
|
|
|
|
$self->perform_subchecks([ |
51
|
|
|
|
|
|
|
[ |
52
|
|
|
|
|
|
|
$$value, |
53
|
|
|
|
|
|
|
$self->{referent}, |
54
|
|
|
|
|
|
|
{ |
55
|
8
|
|
|
1
|
|
78
|
data_path => [ [ 'scalar_deref', 'deref', sub { "\${$_[0]}" } ] ], |
|
1
|
|
|
|
|
232
|
|
56
|
|
|
|
|
|
|
check_path => [ [ 'referent', 'key' ] ], |
57
|
|
|
|
|
|
|
}, |
58
|
|
|
|
|
|
|
], |
59
|
|
|
|
|
|
|
]); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
5
|
|
|
|
|
162
|
return 1; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |