File Coverage

/tmp/rJ4E0FVuWW.mite.pm
Criterion Covered Total %
statement 76 97 78.3
branch 21 44 47.7
condition 6 27 22.2
subroutine 15 16 93.7
pod n/a
total 118 184 64.1


line stmt bran cond sub pod time code
1             {
2             use strict;
3 1     1   6 use warnings;
  1         1  
  1         34  
4 1     1   5 no warnings qw( once void );
  1         1  
  1         39  
5 1     1   5  
  1         2  
  1         140  
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", "MyPerson" );
12 1     1   4 ( *after, *around, *before, *extends, *has, *signature_for, *with ) = do {
13 1         2 no warnings 'redefine';
14             (
15 1     1   6 sub { $SHIM->HANDLE_after( $CALLER, "class", @_ ) },
  1         1  
  1         164  
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 4         14 sub { $SHIM->HANDLE_with( $CALLER, @_ ) },
22 0         0 );
23 0         0 };
24 1         70  
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         748  
31 1   33 1   2 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  1         6  
32 1         6 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       2 HAS_FOREIGNBUILDARGS => $class->can('FOREIGNBUILDARGS'),
  1         21  
  0         0  
40 1         4 };
  1         4  
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 1 50   1   149  
51 1   33     9 # Attribute first_name
52 1         4 # has declaration, file ../../../../tmp/rJ4E0FVuWW, line 3
53 1 50       7 my $args_for_first__name = {};
  0 50       0  
54 1         5 for ( "first_name", "given_name" ) { next unless exists $args->{$_}; $args_for_first__name->{"first_name"} = $args->{$_}; last; };
55             Mite::Shim::croak "Missing key in constructor: first_name" unless exists $args_for_first__name->{"first_name"};
56             $self->{"first_name"} = $args_for_first__name->{"first_name"};
57              
58 1         2 # Attribute last_name
59 1 100       2 # has declaration, file ../../../../tmp/rJ4E0FVuWW, line 7
  2         7  
  1         2  
  1         3  
60 1 50       4 my $args_for_last__name = {};
61 1         5 for ( "last_name", "family_name", "surname" ) { next unless exists $args->{$_}; $args_for_last__name->{"last_name"} = $args->{$_}; last; };
62             Mite::Shim::croak "Missing key in constructor: last_name" unless exists $args_for_last__name->{"last_name"};
63             $self->{"last_name"} = $args_for_last__name->{"last_name"};
64              
65 1         2 # Attribute age
66 1 100       3 # has declaration, file ../../../../tmp/rJ4E0FVuWW, line 11
  3         6  
  1         2  
  1         3  
67 1 50       8 if ( exists $args->{"age"} ) { $self->{"age"} = $args->{"age"}; } ;
68 1         3  
69             # Attribute height
70             # has declaration, file ../../../../tmp/rJ4E0FVuWW, line 14
71             if ( exists $args->{"height"} ) { $self->{"height"} = $args->{"height"}; } ;
72 1 50       3  
  0         0  
73              
74             # Call BUILD methods
75             $self->BUILDALL( $args ) if ( ! $no_build and @{ $meta->{BUILD} || [] } );
76 1 50       4  
  0         0  
77             # Unrecognized parameters
78             my @unknown = grep not( /\A(?:age|f(?:amily_name|irst_name)|given_name|height|last_name|surname)\z/ ), keys %{$args}; @unknown and Mite::Shim::croak( "Unexpected keys in constructor: " . join( q[, ], sort @unknown ) );
79              
80 1 50 33     5 return $self;
  1 50       5  
81             }
82              
83 1 50       2 # Used by constructor to call BUILD methods
  1         12  
  1         4  
84             my $class = ref( $_[0] );
85 1         4 my $meta = ( $Mite::META{$class} ||= $class->__META__ );
86             $_->( @_ ) for @{ $meta->{BUILD} || [] };
87             }
88              
89             # Destructor should call DEMOLISH methods
90 0     0   0 my $self = shift;
91 0   0     0 my $class = ref( $self ) || $self;
92 0 0       0 my $meta = ( $Mite::META{$class} ||= $class->__META__ );
  0         0  
93             my $in_global_destruction = defined ${^GLOBAL_PHASE}
94             ? ${^GLOBAL_PHASE} eq 'DESTRUCT'
95             : Devel::GlobalDestruction::in_global_destruction();
96             for my $demolisher ( @{ $meta->{DEMOLISH} || [] } ) {
97 1     1   689 my $e = do {
98 1   33     5 local ( $?, $@ );
99 1   33     18 eval { $demolisher->( $self, $in_global_destruction ) };
100 1 50       6 $@;
101             };
102             no warnings 'misc'; # avoid (in cleanup) warnings
103 1 50       2 die $e if $e; # rethrow
  1         7  
104 0         0 }
105 0         0 return;
106 0         0 }
  0         0  
107 0         0  
108             my $__XS = !$ENV{PERL_ONLY} && eval { require Class::XSAccessor; Class::XSAccessor->VERSION("1.19") };
109 1     1   7  
  1         2  
  1         629  
110 0 0       0 # Accessors for age
111             # has declaration, file ../../../../tmp/rJ4E0FVuWW, line 11
112 1         5 if ( $__XS ) {
113             Class::XSAccessor->import(
114             chained => 1,
115             "getters" => { "age" => "age" },
116             );
117             }
118             else {
119             *age = sub { @_ == 1 or Mite::Shim::croak( 'Reader "age" usage: $self->age()' ); $_[0]{"age"} };
120             }
121              
122             # Accessors for first_name
123             # has declaration, file ../../../../tmp/rJ4E0FVuWW, line 3
124             if ( $__XS ) {
125             Class::XSAccessor->import(
126             chained => 1,
127             "accessors" => { "first_name" => "first_name" },
128             );
129             }
130             else {
131             *first_name = sub { @_ > 1 ? do { $_[0]{"first_name"} = $_[1]; $_[0]; } : ( $_[0]{"first_name"} ) };
132             }
133              
134             # Aliases for first_name
135             # has declaration, file ../../../../tmp/rJ4E0FVuWW, line 3
136              
137             # Accessors for height
138             # has declaration, file ../../../../tmp/rJ4E0FVuWW, line 14
139             if ( $__XS ) {
140             Class::XSAccessor->import(
141             chained => 1,
142             "getters" => { "height" => "height" },
143 2     2   1695 );
144             }
145             else {
146             *height = sub { @_ == 1 or Mite::Shim::croak( 'Reader "height" usage: $self->height()' ); $_[0]{"height"} };
147             }
148              
149             # Accessors for last_name
150             # has declaration, file ../../../../tmp/rJ4E0FVuWW, line 7
151             if ( $__XS ) {
152             Class::XSAccessor->import(
153             chained => 1,
154             "getters" => { "last_name" => "last_name" },
155             "setters" => { "_set_last_name" => "last_name" },
156             );
157             }
158             else {
159             *last_name = sub { @_ == 1 or Mite::Shim::croak( 'Reader "last_name" usage: $self->last_name()' ); $_[0]{"last_name"} };
160             *_set_last_name = sub { @_ == 2 or Mite::Shim::croak( 'Writer "_set_last_name" usage: $self->_set_last_name( $newvalue )' ); $_[0]{"last_name"} = $_[1]; $_[0]; };
161             }
162              
163             # Aliases for last_name
164             # has declaration, file ../../../../tmp/rJ4E0FVuWW, line 7
165              
166              
167             # See UNIVERSAL
168             my ( $self, $role ) = @_;
169             our %DOES;
170             return $DOES{$role} if exists $DOES{$role};
171             return 1 if $role eq __PACKAGE__;
172             if ( $INC{'Moose/Util.pm'} and my $meta = Moose::Util::find_meta( ref $self or $self ) ) {
173 1     1   7 $meta->can( 'does_role' ) and $meta->does_role( $role ) and return 1;
174 1     1   9 }
175             return $self->SUPER::DOES( $role );
176             }
177              
178             # Alias for Moose/Moo-compatibility
179 7     7   11 shift->DOES( @_ );
180 7         7 }
181 7 50       12  
182 7 50       9 1;