File Coverage

/tmp/waXCOqF6g8.mite.pm
Criterion Covered Total %
statement 81 100 81.0
branch 25 50 50.0
condition 6 27 22.2
subroutine 16 17 94.1
pod n/a
total 128 194 65.9


line stmt bran cond sub pod time code
1             {
2             use Storable ();
3 3     3   33 use strict;
  3         15  
  3         84  
4 3     3   27 use warnings;
  3         24  
  3         135  
5 3     3   12 no warnings qw( once void );
  3         6  
  3         228  
6 3     3   15  
  3         18  
  3         597  
7             our $USES_MITE = "Mite::Class";
8             our $MITE_SHIM = "Mite::Shim";
9             our $MITE_VERSION = "0.011000";
10             # Mite keywords
11             BEGIN {
12             my ( $SHIM, $CALLER ) = ( "Mite::Shim", "MyTest4" );
13 3     3   15 ( *after, *around, *before, *extends, *has, *signature_for, *with ) = do {
14 3         6 no warnings 'redefine';
15             (
16 3     3   21 sub { $SHIM->HANDLE_after( $CALLER, "class", @_ ) },
  3         18  
  3         630  
17             sub { $SHIM->HANDLE_around( $CALLER, "class", @_ ) },
18 0         0 sub { $SHIM->HANDLE_before( $CALLER, "class", @_ ) },
19 0         0 sub {},
20 0         0 sub { $SHIM->HANDLE_has( $CALLER, has => @_ ) },
21             sub { $SHIM->HANDLE_signature_for( $CALLER, "class", @_ ) },
22 12         54 sub { $SHIM->HANDLE_with( $CALLER, @_ ) },
23 0         0 );
24 0         0 };
25 3         156  
26             # Gather metadata for constructor and destructor
27             no strict 'refs';
28             my $class = shift; $class = ref($class) || $class;
29             my $linear_isa = mro::get_linear_isa( $class );
30             return {
31 3     3   27 BUILD => [
  3         9  
  3         2469  
32 3   33 3   3 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  3         15  
33 3         15 map { "$_\::BUILD" } reverse @$linear_isa
34             ],
35             DEMOLISH => [
36 3 50       6 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  3         18  
  0         0  
37 3         9 map { "$_\::DEMOLISH" } @$linear_isa
38             ],
39             HAS_BUILDARGS => $class->can('BUILDARGS'),
40 3 50       3 HAS_FOREIGNBUILDARGS => $class->can('FOREIGNBUILDARGS'),
  3         39  
  0         0  
41 3         6 };
  3         6  
42             }
43              
44              
45             # Standard Moose/Moo-style constructor
46             my $class = ref($_[0]) ? ref(shift) : shift;
47             my $meta = ( $Mite::META{$class} ||= $class->__META__ );
48             my $self = bless {}, $class;
49             my $args = $meta->{HAS_BUILDARGS} ? $class->BUILDARGS( @_ ) : { ( @_ == 1 ) ? %{$_[0]} : @_ };
50             my $no_build = delete $args->{__no_BUILD__};
51 3 50   3   381  
52 3   33     24 # Attribute on_read
53 3         6 # has declaration, file ../../../../tmp/waXCOqF6g8, line 3
54 3 50       27 if ( exists $args->{"on_read"} ) { $self->{"on_read"} = $args->{"on_read"}; } ;
  0 50       0  
55 3         9  
56             # Attribute on_write
57             # has declaration, file ../../../../tmp/waXCOqF6g8, line 9
58             $args->{"on_write"} = Storable::dclone( $args->{"on_write"} ) if exists( $args->{"on_write"} );
59 3 50       6 if ( exists $args->{"on_write"} ) { $self->{"on_write"} = $args->{"on_write"}; } ;
  3         12  
60              
61             # Attribute on_both
62             # has declaration, file ../../../../tmp/waXCOqF6g8, line 15
63 3 50       183 $args->{"on_both"} = Storable::dclone( $args->{"on_both"} ) if exists( $args->{"on_both"} );
64 3 50       12 if ( exists $args->{"on_both"} ) { $self->{"on_both"} = $args->{"on_both"}; } ;
  3         15  
65              
66             # Attribute on_neither
67             # has declaration, file ../../../../tmp/waXCOqF6g8, line 21
68 3 50       30 if ( exists $args->{"on_neither"} ) { $self->{"on_neither"} = $args->{"on_neither"}; } ;
69 3 50       12  
  3         6  
70              
71             # Call BUILD methods
72             $self->BUILDALL( $args ) if ( ! $no_build and @{ $meta->{BUILD} || [] } );
73 3 50       18  
  3         6  
74             # Unrecognized parameters
75             my @unknown = grep not( /\Aon_(?:both|neither|read|write)\z/ ), keys %{$args}; @unknown and Mite::Shim::croak( "Unexpected keys in constructor: " . join( q[, ], sort @unknown ) );
76              
77 3 50 33     6 return $self;
  3 50       15  
78             }
79              
80 3 50       3 # Used by constructor to call BUILD methods
  3         27  
  3         12  
81             my $class = ref( $_[0] );
82 3         12 my $meta = ( $Mite::META{$class} ||= $class->__META__ );
83             $_->( @_ ) for @{ $meta->{BUILD} || [] };
84             }
85              
86             # Destructor should call DEMOLISH methods
87 0     0   0 my $self = shift;
88 0   0     0 my $class = ref( $self ) || $self;
89 0 0       0 my $meta = ( $Mite::META{$class} ||= $class->__META__ );
  0         0  
90             my $in_global_destruction = defined ${^GLOBAL_PHASE}
91             ? ${^GLOBAL_PHASE} eq 'DESTRUCT'
92             : Devel::GlobalDestruction::in_global_destruction();
93             for my $demolisher ( @{ $meta->{DEMOLISH} || [] } ) {
94 3     3   1344 my $e = do {
95 3   33     9 local ( $?, $@ );
96 3   33     9 eval { $demolisher->( $self, $in_global_destruction ) };
97 3 50       12 $@;
98             };
99             no warnings 'misc'; # avoid (in cleanup) warnings
100 3 50       3 die $e if $e; # rethrow
  3         12  
101 0         0 }
102 0         0 return;
103 0         0 }
  0         0  
104 0         0  
105             my $__XS = !$ENV{PERL_ONLY} && eval { require Class::XSAccessor; Class::XSAccessor->VERSION("1.19") };
106 3     3   21  
  3         3  
  3         1629  
107 0 0       0 # Accessors for on_both
108             # has declaration, file ../../../../tmp/waXCOqF6g8, line 15
109 3         12  
110             # Accessors for on_neither
111             # has declaration, file ../../../../tmp/waXCOqF6g8, line 21
112             if ( $__XS ) {
113             Class::XSAccessor->import(
114             chained => 1,
115             "accessors" => { "on_neither" => "on_neither" },
116 6 100   6   132 );
  3         18  
  3         6  
  3         3  
117             }
118             else {
119             *on_neither = sub { @_ > 1 ? do { $_[0]{"on_neither"} = $_[1]; $_[0]; } : ( $_[0]{"on_neither"} ) };
120             }
121              
122             # Accessors for on_read
123             # has declaration, file ../../../../tmp/waXCOqF6g8, line 3
124              
125             # Accessors for on_write
126             # has declaration, file ../../../../tmp/waXCOqF6g8, line 9
127              
128              
129             # See UNIVERSAL
130             my ( $self, $role ) = @_;
131             our %DOES;
132 6 100   6   14364 return $DOES{$role} if exists $DOES{$role};
  3         9  
  3         6  
133             return 1 if $role eq __PACKAGE__;
134             if ( $INC{'Moose/Util.pm'} and my $meta = Moose::Util::find_meta( ref $self or $self ) ) {
135             $meta->can( 'does_role' ) and $meta->does_role( $role ) and return 1;
136 6 100   6   27 }
  3         99  
  3         9  
  3         6  
137             return $self->SUPER::DOES( $role );
138             }
139              
140             # Alias for Moose/Moo-compatibility
141 21     21   30 shift->DOES( @_ );
142 21         15 }
143 21 50       51  
144 21 50       27 1;