File Coverage

/tmp/bTBlES7r7H.mite.pm
Criterion Covered Total %
statement 61 80 76.2
branch 17 36 47.2
condition 7 27 25.9
subroutine 12 13 92.3
pod n/a
total 97 156 62.1


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