File Coverage

/tmp/E0FVuWWVMM.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 4     4   28 use strict;
  4         8  
  4         92  
4 4     4   16 use warnings;
  4         4  
  4         96  
5 4     4   16 no warnings qw( once void );
  4         4  
  4         156  
6 4     4   16  
  4         4  
  4         648  
7             our $USES_MITE = "Mite::Class";
8             our $MITE_SHIM = "Mite::Shim";
9             our $MITE_VERSION = "0.010008";
10             # Mite keywords
11             BEGIN {
12             my ( $SHIM, $CALLER ) = ( "Mite::Shim", "MyTest4" );
13 4     4   16 ( *after, *around, *before, *extends, *has, *signature_for, *with ) = do {
14 4         4 no warnings 'redefine';
15             (
16 4     4   24 sub { $SHIM->HANDLE_after( $CALLER, "class", @_ ) },
  4         4  
  4         692  
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 16         60 sub { $SHIM->HANDLE_with( $CALLER, @_ ) },
23 0         0 );
24 0         0 };
25 4         212  
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 4     4   24 BUILD => [
  4         4  
  4         2876  
32 4   33 4   8 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  4         24  
33 4         28 map { "$_\::BUILD" } reverse @$linear_isa
34             ],
35             DEMOLISH => [
36 4 50       8 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  4         52  
  0         0  
37 4         24 map { "$_\::DEMOLISH" } @$linear_isa
38             ],
39             HAS_BUILDARGS => $class->can('BUILDARGS'),
40 4 50       8 HAS_FOREIGNBUILDARGS => $class->can('FOREIGNBUILDARGS'),
  4         68  
  0         0  
41 4         20 };
  4         16  
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 4 50   4   644  
52 4   33     40 # Attribute on_read
53 4         12 # has declaration, file ../../../../tmp/E0FVuWWVMM, line 3
54 4 50       48 if ( exists $args->{"on_read"} ) { $self->{"on_read"} = $args->{"on_read"}; } ;
  0 50       0  
55 4         12  
56             # Attribute on_write
57             # has declaration, file ../../../../tmp/E0FVuWWVMM, line 9
58             $args->{"on_write"} = Storable::dclone( $args->{"on_write"} ) if exists( $args->{"on_write"} );
59 4 50       16 if ( exists $args->{"on_write"} ) { $self->{"on_write"} = $args->{"on_write"}; } ;
  4         16  
60              
61             # Attribute on_both
62             # has declaration, file ../../../../tmp/E0FVuWWVMM, line 15
63 4 50       368 $args->{"on_both"} = Storable::dclone( $args->{"on_both"} ) if exists( $args->{"on_both"} );
64 4 50       24 if ( exists $args->{"on_both"} ) { $self->{"on_both"} = $args->{"on_both"}; } ;
  4         8  
65              
66             # Attribute on_neither
67             # has declaration, file ../../../../tmp/E0FVuWWVMM, line 21
68 4 50       60 if ( exists $args->{"on_neither"} ) { $self->{"on_neither"} = $args->{"on_neither"}; } ;
69 4 50       12  
  4         12  
70              
71             # Call BUILD methods
72             $self->BUILDALL( $args ) if ( ! $no_build and @{ $meta->{BUILD} || [] } );
73 4 50       8  
  4         8  
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 4 50 33     20 return $self;
  4 50       24  
78             }
79              
80 4 50       12 # Used by constructor to call BUILD methods
  4         52  
  4         16  
81             my $class = ref( $_[0] );
82 4         16 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 4     4   1848 my $e = do {
95 4   33     24 local ( $?, $@ );
96 4   33     20 eval { $demolisher->( $self, $in_global_destruction ) };
97 4 50       20 $@;
98             };
99             no warnings 'misc'; # avoid (in cleanup) warnings
100 4 50       8 die $e if $e; # rethrow
  4         28  
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 4     4   32  
  4         4  
  4         2060  
107 0 0       0 # Accessors for on_both
108             # has declaration, file ../../../../tmp/E0FVuWWVMM, line 15
109 4         140  
110             # Accessors for on_neither
111             # has declaration, file ../../../../tmp/E0FVuWWVMM, line 21
112             if ( $__XS ) {
113             Class::XSAccessor->import(
114             chained => 1,
115             "accessors" => { "on_neither" => "on_neither" },
116 8 100   8   104 );
  4         32  
  4         12  
  4         12  
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/E0FVuWWVMM, line 3
124              
125             # Accessors for on_write
126             # has declaration, file ../../../../tmp/E0FVuWWVMM, line 9
127              
128              
129             # See UNIVERSAL
130             my ( $self, $role ) = @_;
131             our %DOES;
132 8 100   8   21532 return $DOES{$role} if exists $DOES{$role};
  4         12  
  4         12  
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 8 100   8   56 }
  4         184  
  4         16  
  4         12  
137             return $self->SUPER::DOES( $role );
138             }
139              
140             # Alias for Moose/Moo-compatibility
141 28     28   44 shift->DOES( @_ );
142 28         28 }
143 28 50       44  
144 28 50       40 1;