File Coverage

blib/lib/Data/Object/Role/Constructor.pm
Criterion Covered Total %
statement 14 16 87.5
branch 4 6 66.6
condition 7 12 58.3
subroutine 4 4 100.0
pod 0 1 0.0
total 29 39 74.3


line stmt bran cond sub pod time code
1             # Generic Constructor Role for Perl 5
2             package Data::Object::Role::Constructor;
3              
4 15     15   7495 use 5.010;
  15         45  
5 15     15   65 use Data::Object::Role;
  15         22  
  15         125  
6              
7 15     15   3885 use Scalar::Util 'blessed';
  15         33  
  15         2980  
8              
9             our $VERSION = '0.41'; # VERSION
10              
11             sub new {
12 10     10 0 10120 my $class = shift;
13 10         23 my $data = shift;
14              
15 10         22 my $role = 'Data::Object::Role::Type';
16              
17 10 50 66     118 $data = $data->data if blessed($data)
      33        
18             and $data->can('does')
19             and $data->does($role);
20              
21 10 50 66     99 if (blessed($data) && $data->isa('Regexp') && $^V <= v5.12.0) {
      66        
22 0         0 $data = do {\(my $q = qr/$data/)};
  0         0  
23             }
24              
25 10 100       67 return bless ref($data) ? $data : \$data, $class;
26             }
27              
28             1;