File Coverage

/tmp/s7p7G_Hxl6.mite.pm
Criterion Covered Total %
statement 65 84 77.3
branch 16 38 42.1
condition 6 27 22.2
subroutine 14 15 93.3
pod n/a
total 101 164 61.5


line stmt bran cond sub pod time code
1             {
2             use Storable ();
3 4     4   28 use strict;
  4         4  
  4         108  
4 4     4   20 use warnings;
  4         8  
  4         76  
5 4     4   16 no warnings qw( once void );
  4         4  
  4         156  
6 4     4   24  
  4         4  
  4         632  
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", "MyTest" );
13 4     4   52 ( *after, *around, *before, *extends, *has, *signature_for, *with ) = do {
14 4         8 no warnings 'redefine';
15             (
16 4     4   28 sub { $SHIM->HANDLE_after( $CALLER, "class", @_ ) },
  4         4  
  4         712  
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 4         24 sub { $SHIM->HANDLE_with( $CALLER, @_ ) },
23 0         0 );
24 0         0 };
25 4         172  
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         8  
  4         2620  
32 4   33 4   4 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  4         20  
33 4         20 map { "$_\::BUILD" } reverse @$linear_isa
34             ],
35             DEMOLISH => [
36 4 50       4 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  4         32  
  0         0  
37 4         20 map { "$_\::DEMOLISH" } @$linear_isa
38             ],
39             HAS_BUILDARGS => $class->can('BUILDARGS'),
40 4 50       8 HAS_FOREIGNBUILDARGS => $class->can('FOREIGNBUILDARGS'),
  4         60  
  0         0  
41 4         8 };
  4         12  
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   620  
52 4   33     28 # Attribute foo
53 4         12 # has declaration, file ../../../../tmp/s7p7G_Hxl6, line 3
54 4 50       28 $args->{"foo"} = Storable::dclone( $args->{"foo"} ) if exists( $args->{"foo"} );
  0 50       0  
55 4         8 if ( exists $args->{"foo"} ) { $self->{"foo"} = $args->{"foo"}; } ;
56              
57              
58             # Call BUILD methods
59 4 50       288 $self->BUILDALL( $args ) if ( ! $no_build and @{ $meta->{BUILD} || [] } );
60 4 50       16  
  4         24  
61             # Unrecognized parameters
62             my @unknown = grep not( /\Afoo\z/ ), keys %{$args}; @unknown and Mite::Shim::croak( "Unexpected keys in constructor: " . join( q[, ], sort @unknown ) );
63              
64 4 50 33     16 return $self;
  4 50       28  
65             }
66              
67 4 50       8 # Used by constructor to call BUILD methods
  4         24  
  4         16  
68             my $class = ref( $_[0] );
69 4         36 my $meta = ( $Mite::META{$class} ||= $class->__META__ );
70             $_->( @_ ) for @{ $meta->{BUILD} || [] };
71             }
72              
73             # Destructor should call DEMOLISH methods
74 0     0   0 my $self = shift;
75 0   0     0 my $class = ref( $self ) || $self;
76 0 0       0 my $meta = ( $Mite::META{$class} ||= $class->__META__ );
  0         0  
77             my $in_global_destruction = defined ${^GLOBAL_PHASE}
78             ? ${^GLOBAL_PHASE} eq 'DESTRUCT'
79             : Devel::GlobalDestruction::in_global_destruction();
80             for my $demolisher ( @{ $meta->{DEMOLISH} || [] } ) {
81 4     4   9792 my $e = do {
82 4   33     16 local ( $?, $@ );
83 4   33     20 eval { $demolisher->( $self, $in_global_destruction ) };
84 4 50       24 $@;
85             };
86             no warnings 'misc'; # avoid (in cleanup) warnings
87 4 50       12 die $e if $e; # rethrow
  4         20  
88 0         0 }
89 0         0 return;
90 0         0 }
  0         0  
91 0         0  
92             my $__XS = !$ENV{PERL_ONLY} && eval { require Class::XSAccessor; Class::XSAccessor->VERSION("1.19") };
93 4     4   28  
  4         8  
  4         1304  
94 0 0       0 # Accessors for foo
95             # has declaration, file ../../../../tmp/s7p7G_Hxl6, line 3
96 4         44  
97              
98             # See UNIVERSAL
99             my ( $self, $role ) = @_;
100             our %DOES;
101             return $DOES{$role} if exists $DOES{$role};
102             return 1 if $role eq __PACKAGE__;
103 4 50   4   44 if ( $INC{'Moose/Util.pm'} and my $meta = Moose::Util::find_meta( ref $self or $self ) ) {
  4         52  
104             $meta->can( 'does_role' ) and $meta->does_role( $role ) and return 1;
105             }
106             return $self->SUPER::DOES( $role );
107             }
108 28     28   52  
109 28         20 # Alias for Moose/Moo-compatibility
110 28 50       60 shift->DOES( @_ );
111 28 50       40 }
112 28 50 0     56  
      33        
113 0 0 0     0 1;