File Coverage

/tmp/D3UeTP8ZoG.mite.pm
Criterion Covered Total %
statement 68 88 77.2
branch 21 44 47.7
condition 7 27 25.9
subroutine 14 15 93.3
pod n/a
total 110 174 63.2


line stmt bran cond sub pod time code
1             {
2             package MyTest3;
3 2     2   16 use strict;
  2         14  
  2         144  
4 2     2   24 use warnings;
  2         14  
  2         188  
5 2     2   12 no warnings qw( once void );
  2         4  
  2         460  
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 2     2   28 my ( $SHIM, $CALLER ) = ( "Mite::Shim", "MyTest3" );
13 2         16 ( *after, *around, *before, *extends, *has, *signature_for, *with ) = do {
14             package Mite::Shim;
15 2     2   34 no warnings 'redefine';
  2         6  
  2         560  
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         40 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 2         244 );
25             };
26             };
27              
28             # Gather metadata for constructor and destructor
29             sub __META__ {
30 2     2   30 no strict 'refs';
  2         6  
  2         1798  
31 2   33 2   4 my $class = shift; $class = ref($class) || $class;
  2         118  
32 2         14 my $linear_isa = mro::get_linear_isa( $class );
33             return {
34             BUILD => [
35 2 50       2 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  2         26  
  0         0  
36 2         8 map { "$_\::BUILD" } reverse @$linear_isa
37             ],
38             DEMOLISH => [
39 2 50       4 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  2         36  
  0         0  
40 2         8 map { "$_\::DEMOLISH" } @$linear_isa
  2         10  
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 4 50   4   428 my $class = ref($_[0]) ? ref(shift) : shift;
51 4   66     68 my $meta = ( $Mite::META{$class} ||= $class->__META__ );
52 4         12 my $self = bless {}, $class;
53 4 50       64 my $args = $meta->{HAS_BUILDARGS} ? $class->BUILDARGS( @_ ) : { ( @_ == 1 ) ? %{$_[0]} : @_ };
  0 50       0  
54 4         12 my $no_build = delete $args->{__no_BUILD__};
55              
56             # Attribute attr
57             # has declaration, file ../../../../tmp/D3UeTP8ZoG, line 3
58 4 100       36 $self->{"attr"} = ( exists( $args->{"attr"} ) ? $args->{"attr"} : "default" ); $self->_trigger_attr( $self->{"attr"} );
  4         30  
59              
60             # Attribute log
61             # has declaration, file ../../../../tmp/D3UeTP8ZoG, line 11
62 4 50       14 if ( exists $args->{"log"} ) { $self->{"log"} = $args->{"log"}; } ;
  0         0  
63              
64              
65             # Call BUILD methods
66 4 50 33     16 $self->BUILDALL( $args ) if ( ! $no_build and @{ $meta->{BUILD} || [] } );
  4 50       118  
67              
68             # Unrecognized parameters
69 4 50       34 my @unknown = grep not( /\A(?:attr|log)\z/ ), keys %{$args}; @unknown and Mite::Shim::croak( "Unexpected keys in constructor: " . join( q[, ], sort @unknown ) );
  4         28  
  4         48  
70              
71 4         36 return $self;
72             }
73              
74             # Used by constructor to call BUILD methods
75             sub BUILDALL {
76 0     0   0 my $class = ref( $_[0] );
77 0   0     0 my $meta = ( $Mite::META{$class} ||= $class->__META__ );
78 0 0       0 $_->( @_ ) for @{ $meta->{BUILD} || [] };
  0         0  
79             }
80              
81             # Destructor should call DEMOLISH methods
82             sub DESTROY {
83 4     4   13256 my $self = shift;
84 4   33     14 my $class = ref( $self ) || $self;
85 4   33     14 my $meta = ( $Mite::META{$class} ||= $class->__META__ );
86 4 50       16 my $in_global_destruction = defined ${^GLOBAL_PHASE}
87             ? ${^GLOBAL_PHASE} eq 'DESTRUCT'
88             : Devel::GlobalDestruction::in_global_destruction();
89 4 50       8 for my $demolisher ( @{ $meta->{DEMOLISH} || [] } ) {
  4         14  
90 0         0 my $e = do {
91 0         0 local ( $?, $@ );
92 0         0 eval { $demolisher->( $self, $in_global_destruction ) };
  0         0  
93 0         0 $@;
94             };
95 2     2   16 no warnings 'misc'; # avoid (in cleanup) warnings
  2         6  
  2         1240  
96 0 0       0 die $e if $e; # rethrow
97             }
98 4         16 return;
99             }
100              
101             my $__XS = !$ENV{PERL_ONLY} && eval { require Class::XSAccessor; Class::XSAccessor->VERSION("1.19") };
102              
103             # Accessors for attr
104             # has declaration, file ../../../../tmp/D3UeTP8ZoG, line 3
105 8 50   8   1680 sub attr { @_ > 1 ? do { my @oldvalue; @oldvalue = $_[0]{"attr"} if exists $_[0]{"attr"}; $_[0]{"attr"} = $_[1]; $_[0]->_trigger_attr( $_[0]{"attr"}, @oldvalue ); $_[0]; } : ( $_[0]{"attr"} ) }
  8 50       18  
  8         30  
  8         60  
  8         92  
  8         18  
106              
107             # Accessors for log
108             # has declaration, file ../../../../tmp/D3UeTP8ZoG, line 11
109 16 50   16   44 sub log { @_ == 1 or Mite::Shim::croak( 'Reader "log" usage: $self->log()' ); ( exists($_[0]{"log"}) ? $_[0]{"log"} : ( $_[0]{"log"} = $MyTest3::__log_DEFAULT__->( $_[0] ) ) ) }
  16 100       146  
110              
111              
112             # See UNIVERSAL
113             sub DOES {
114 14     14   34 my ( $self, $role ) = @_;
115 14         18 our %DOES;
116 14 50       40 return $DOES{$role} if exists $DOES{$role};
117 14 50       40 return 1 if $role eq __PACKAGE__;
118 14 50 0     44 if ( $INC{'Moose/Util.pm'} and my $meta = Moose::Util::find_meta( ref $self or $self ) ) {
      33        
119 0 0 0     0 $meta->can( 'does_role' ) and $meta->does_role( $role ) and return 1;
120             }
121 14         130 return $self->SUPER::DOES( $role );
122             }
123              
124             # Alias for Moose/Moo-compatibility
125             sub does {
126 14     14   2144 shift->DOES( @_ );
127             }
128              
129             1;
130             }