File Coverage

/tmp/sll_90CvRH.mite.pm
Criterion Covered Total %
statement 61 80 76.2
branch 18 40 45.0
condition 7 27 25.9
subroutine 12 13 92.3
pod n/a
total 98 160 61.2


line stmt bran cond sub pod time code
1             {
2             package Foo;
3 1     1   6 use strict;
  1         2  
  1         30  
4 1     1   4 use warnings;
  1         2  
  1         28  
5 1     1   5 no warnings qw( once void );
  1         1  
  1         158  
6              
7             our $USES_MITE = "Mite::Class";
8             our $MITE_SHIM = "Mite::Shim";
9             our $MITE_VERSION = "0.012000";
10             # Mite keywords
11             BEGIN {
12 1     1   4 my ( $SHIM, $CALLER ) = ( "Mite::Shim", "Foo" );
13 1         6 ( *after, *around, *before, *extends, *has, *signature_for, *with ) = do {
14             package Mite::Shim;
15 1     1   7 no warnings 'redefine';
  1         1  
  1         219  
16             (
17 0         0 sub { $SHIM->HANDLE_after( $CALLER, "class", @_ ) },
18 0         0 sub { $SHIM->HANDLE_around( $CALLER, "class", @_ ) },
19 0         0 sub { $SHIM->HANDLE_before( $CALLER, "class", @_ ) },
20             sub {},
21 4         12 sub { $SHIM->HANDLE_has( $CALLER, has => @_ ) },
22 0         0 sub { $SHIM->HANDLE_signature_for( $CALLER, "class", @_ ) },
23 0         0 sub { $SHIM->HANDLE_with( $CALLER, @_ ) },
24 1         55 );
25             };
26             };
27              
28             # Gather metadata for constructor and destructor
29             sub __META__ {
30 1     1   13 no strict 'refs';
  1         2  
  1         760  
31 1   33 1   2 my $class = shift; $class = ref($class) || $class;
  1         5  
32 1         5 my $linear_isa = mro::get_linear_isa( $class );
33             return {
34             BUILD => [
35 1 50       2 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  1         6  
  0         0  
36 1         4 map { "$_\::BUILD" } reverse @$linear_isa
37             ],
38             DEMOLISH => [
39 1 50       1 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  1         25  
  0         0  
40 1         2 map { "$_\::DEMOLISH" } @$linear_isa
  1         3  
41             ],
42             HAS_BUILDARGS => $class->can('BUILDARGS'),
43             HAS_FOREIGNBUILDARGS => $class->can('FOREIGNBUILDARGS'),
44             };
45             }
46              
47              
48             # Standard Moose/Moo-style constructor
49             sub new {
50 7 50   7   18683 my $class = ref($_[0]) ? ref(shift) : shift;
51 7   66     25 my $meta = ( $Mite::META{$class} ||= $class->__META__ );
52 7         15 my $self = bless {}, $class;
53 7 50       22 my $args = $meta->{HAS_BUILDARGS} ? $class->BUILDARGS( @_ ) : { ( @_ == 1 ) ? %{$_[0]} : @_ };
  0 50       0  
54 7         9 my $no_build = delete $args->{__no_BUILD__};
55              
56             # Attribute number
57             # has declaration, file ../../../../tmp/sll_90CvRH, line 11
58 7 100       21 $self->{"number"} = ( exists( $args->{"number"} ) ? $args->{"number"} : $Foo::__number_DEFAULT__->( $self ) );
59              
60             # Attribute list
61             # has declaration, file ../../../../tmp/sll_90CvRH, line 15
62 7 50       18 $self->{"list"} = ( exists( $args->{"list"} ) ? $args->{"list"} : $Foo::__list_DEFAULT__->( $self ) );
63              
64             # Attribute closure
65             # has declaration, file ../../../../tmp/sll_90CvRH, line 20
66 7 50       19 $self->{"closure"} = ( exists( $args->{"closure"} ) ? $args->{"closure"} : $Foo::__closure_DEFAULT__->( $self ) );
67              
68             # Attribute counter
69             # has declaration, file ../../../../tmp/sll_90CvRH, line 28
70 7 50       17 $self->{"counter"} = ( exists( $args->{"counter"} ) ? $args->{"counter"} : $Foo::__counter_DEFAULT__->( $self ) );
71              
72              
73             # Call BUILD methods
74 7 50 33     18 $self->BUILDALL( $args ) if ( ! $no_build and @{ $meta->{BUILD} || [] } );
  7 50       34  
75              
76             # Unrecognized parameters
77 7 50       10 my @unknown = grep not( /\A(?:c(?:losure|ounter)|list|number)\z/ ), keys %{$args}; @unknown and Mite::Shim::croak( "Unexpected keys in constructor: " . join( q[, ], sort @unknown ) );
  7         29  
  7         16  
78              
79 7         25 return $self;
80             }
81              
82             # Used by constructor to call BUILD methods
83             sub BUILDALL {
84 0     0   0 my $class = ref( $_[0] );
85 0   0     0 my $meta = ( $Mite::META{$class} ||= $class->__META__ );
86 0 0       0 $_->( @_ ) for @{ $meta->{BUILD} || [] };
  0         0  
87             }
88              
89             # Destructor should call DEMOLISH methods
90             sub DESTROY {
91 7     7   8597 my $self = shift;
92 7   33     20 my $class = ref( $self ) || $self;
93 7   33     15 my $meta = ( $Mite::META{$class} ||= $class->__META__ );
94 7 50       22 my $in_global_destruction = defined ${^GLOBAL_PHASE}
95             ? ${^GLOBAL_PHASE} eq 'DESTRUCT'
96             : Devel::GlobalDestruction::in_global_destruction();
97 7 50       7 for my $demolisher ( @{ $meta->{DEMOLISH} || [] } ) {
  7         46  
98 0         0 my $e = do {
99 0         0 local ( $?, $@ );
100 0         0 eval { $demolisher->( $self, $in_global_destruction ) };
  0         0  
101 0         0 $@;
102             };
103 1     1   10 no warnings 'misc'; # avoid (in cleanup) warnings
  1         2  
  1         639  
104 0 0       0 die $e if $e; # rethrow
105             }
106 7         26 return;
107             }
108              
109             my $__XS = !$ENV{PERL_ONLY} && eval { require Class::XSAccessor; Class::XSAccessor->VERSION("1.19") };
110              
111             # Accessors for closure
112             # has declaration, file ../../../../tmp/sll_90CvRH, line 20
113             if ( $__XS ) {
114             Class::XSAccessor->import(
115             chained => 1,
116             "accessors" => { "closure" => "closure" },
117             );
118             }
119             else {
120             *closure = sub { @_ > 1 ? do { $_[0]{"closure"} = $_[1]; $_[0]; } : ( $_[0]{"closure"} ) };
121             }
122              
123             # Accessors for counter
124             # has declaration, file ../../../../tmp/sll_90CvRH, line 28
125             if ( $__XS ) {
126             Class::XSAccessor->import(
127             chained => 1,
128             "accessors" => { "counter" => "counter" },
129             );
130             }
131             else {
132             *counter = sub { @_ > 1 ? do { $_[0]{"counter"} = $_[1]; $_[0]; } : ( $_[0]{"counter"} ) };
133             }
134              
135             # Accessors for list
136             # has declaration, file ../../../../tmp/sll_90CvRH, line 15
137             if ( $__XS ) {
138             Class::XSAccessor->import(
139             chained => 1,
140             "accessors" => { "list" => "list" },
141             );
142             }
143             else {
144             *list = sub { @_ > 1 ? do { $_[0]{"list"} = $_[1]; $_[0]; } : ( $_[0]{"list"} ) };
145             }
146              
147             # Accessors for number
148             # has declaration, file ../../../../tmp/sll_90CvRH, line 11
149             if ( $__XS ) {
150             Class::XSAccessor->import(
151             chained => 1,
152             "accessors" => { "number" => "number" },
153             );
154             }
155             else {
156             *number = sub { @_ > 1 ? do { $_[0]{"number"} = $_[1]; $_[0]; } : ( $_[0]{"number"} ) };
157             }
158              
159              
160             # See UNIVERSAL
161             sub DOES {
162 7     7   11 my ( $self, $role ) = @_;
163 7         7 our %DOES;
164 7 50       15 return $DOES{$role} if exists $DOES{$role};
165 7 50       11 return 1 if $role eq __PACKAGE__;
166 7 50 0     14 if ( $INC{'Moose/Util.pm'} and my $meta = Moose::Util::find_meta( ref $self or $self ) ) {
      33        
167 0 0 0     0 $meta->can( 'does_role' ) and $meta->does_role( $role ) and return 1;
168             }
169 7         35 return $self->SUPER::DOES( $role );
170             }
171              
172             # Alias for Moose/Moo-compatibility
173             sub does {
174 7     7   2053 shift->DOES( @_ );
175             }
176              
177             1;
178             }