File Coverage

blib/lib/Data/Object/Code.pm
Criterion Covered Total %
statement 23 23 100.0
branch 2 4 50.0
condition 2 6 33.3
subroutine 8 8 100.0
pod 0 3 0.0
total 35 44 79.5


line stmt bran cond sub pod time code
1             # ABSTRACT: A Code Object for Perl 5
2             package Data::Object::Code;
3              
4 19     19   10540 use 5.010;
  19         73  
  19         822  
5              
6 19     19   91 use Carp 'confess';
  19         22  
  19         1347  
7 19     19   124 use Scalar::Util 'blessed';
  19         30  
  19         1216  
8 19     19   4264 use Data::Object 'deduce_deep', 'detract_deep';
  19         45  
  19         1282  
9 19     19   4988 use Data::Object::Class 'with';
  19         334  
  19         188  
10              
11             with 'Data::Object::Role::Code';
12              
13             our $VERSION = '0.20'; # VERSION
14              
15             sub new {
16 24     24 0 18942 my $class = shift;
17 24         45 my $data = shift;
18              
19 24   33     135 $class = ref($class) || $class;
20 24 50 33     154 unless (blessed($data) && $data->isa($class)) {
21 24 50       93 confess 'Type Instantiation Error: Not a CodeRef'
22             unless 'CODE' eq ref $data;
23             }
24              
25 24         109 return bless $data, $class;
26             }
27              
28             around 'call' => sub {
29             my ($orig, $self, @args) = @_;
30             my $result = $self->$orig(@args);
31             return scalar deduce_deep $result;
32             };
33              
34             around 'compose' => sub {
35             my ($orig, $self, @args) = @_;
36             my $next = deduce_deep shift @args;
37             my $result = $self->$orig($next, @args);
38             return scalar deduce_deep $result;
39             };
40              
41             around 'conjoin' => sub {
42             my ($orig, $self, @args) = @_;
43             my $next = deduce_deep shift @args;
44             my $result = $self->$orig($next, @args);
45             return scalar deduce_deep $result;
46             };
47              
48             around 'curry' => sub {
49             my ($orig, $self, @args) = @_;
50             my $result = $self->$orig(@args);
51             return scalar deduce_deep $result;
52             };
53              
54             sub data {
55 2     2 0 8 goto &detract;
56             }
57              
58             sub detract {
59 4     4 0 15 return detract_deep shift;
60             }
61              
62             around 'disjoin' => sub {
63             my ($orig, $self, @args) = @_;
64             my $next = deduce_deep shift @args;
65             my $result = $self->$orig($next, @args);
66             return scalar deduce_deep $result;
67             };
68              
69             around 'next' => sub {
70             my ($orig, $self, @args) = @_;
71             my $result = $self->$orig(@args);
72             return scalar deduce_deep $result;
73             };
74              
75             around 'rcurry' => sub {
76             my ($orig, $self, @args) = @_;
77             my $result = $self->$orig(@args);
78             return scalar deduce_deep $result;
79             };
80              
81             1;
82              
83             __END__