File | /usr/local/lib/perl5/site_perl/5.10.1/MooseX/Types/UndefinedType.pm |
Statements Executed | 96 |
Statement Execution Time | 573µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
50 | 2 | 2 | 73µs | 73µs | name | MooseX::Types::UndefinedType::
10 | 1 | 1 | 52µs | 52µs | new | MooseX::Types::UndefinedType::
10 | 1 | 1 | 34µs | 46µs | __ANON__[:15] | MooseX::Types::UndefinedType::
1 | 1 | 1 | 16µs | 34µs | BEGIN@9 | MooseX::Types::UndefinedType::
1 | 1 | 1 | 10µs | 50µs | BEGIN@15 | MooseX::Types::UndefinedType::
10 | 10 | 1 | 9µs | 9µs | DESTROY | MooseX::Types::UndefinedType::
1 | 1 | 1 | 8µs | 12µs | BEGIN@10 | MooseX::Types::UndefinedType::
1 | 1 | 1 | 7µs | 110µs | BEGIN@13 | MooseX::Types::UndefinedType::
1 | 1 | 1 | 3µs | 3µs | BEGIN@12 | MooseX::Types::UndefinedType::
0 | 0 | 0 | 0s | 0s | AUTOLOAD | MooseX::Types::UndefinedType::
0 | 0 | 0 | 0s | 0s | __autovivify | MooseX::Types::UndefinedType::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package MooseX::Types::UndefinedType; | ||||
2 | |||||
3 | =head1 NAME | ||||
4 | |||||
5 | MooseX::Types::UndefinedType - Represents a not yet defined type | ||||
6 | |||||
7 | =cut | ||||
8 | |||||
9 | 3 | 23µs | 2 | 52µs | # spent 34µs (16+18) within MooseX::Types::UndefinedType::BEGIN@9 which was called
# once (16µs+18µs) by MooseX::Types::BEGIN@14 at line 9 # spent 34µs making 1 call to MooseX::Types::UndefinedType::BEGIN@9
# spent 18µs making 1 call to warnings::import |
10 | 3 | 18µs | 2 | 16µs | # spent 12µs (8+4) within MooseX::Types::UndefinedType::BEGIN@10 which was called
# once (8µs+4µs) by MooseX::Types::BEGIN@14 at line 10 # spent 12µs making 1 call to MooseX::Types::UndefinedType::BEGIN@10
# spent 4µs making 1 call to strict::import |
11 | |||||
12 | 3 | 18µs | 1 | 3µs | # spent 3µs within MooseX::Types::UndefinedType::BEGIN@12 which was called
# once (3µs+0s) by MooseX::Types::BEGIN@14 at line 12 # spent 3µs making 1 call to MooseX::Types::UndefinedType::BEGIN@12 |
13 | 3 | 46µs | 2 | 212µs | # spent 110µs (7+103) within MooseX::Types::UndefinedType::BEGIN@13 which was called
# once (7µs+103µs) by MooseX::Types::BEGIN@14 at line 13 # spent 110µs making 1 call to MooseX::Types::UndefinedType::BEGIN@13
# spent 103µs making 1 call to Carp::Clan::import |
14 | |||||
15 | 10 | 27µs | 10 | 12µs | # spent 46µs (34+12) within MooseX::Types::UndefinedType::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/MooseX/Types/UndefinedType.pm:15] which was called 10 times, avg 5µs/call:
# 10 times (34µs+12µs) by MooseX::Types::TypeDecorator::new at line 69 of MooseX/Types/TypeDecorator.pm, avg 5µs/call
# spent 50µs (10+39) within MooseX::Types::UndefinedType::BEGIN@15 which was called
# once (10µs+39µs) by MooseX::Types::BEGIN@14 at line 16 # spent 12µs making 10 calls to MooseX::Types::UndefinedType::name, avg 1µs/call |
16 | 3 | 229µs | 2 | 89µs | fallback => 1; # spent 50µs making 1 call to MooseX::Types::UndefinedType::BEGIN@15
# spent 39µs making 1 call to overload::import |
17 | |||||
18 | =head1 DESCRIPTION | ||||
19 | |||||
20 | Whenever a type handle function (e.g. C<Int()> can't find a type | ||||
21 | constraint under it's full name, it assumes it has not yet been defined. | ||||
22 | It will then return an instance of this class, handling only | ||||
23 | stringification, name and possible identification of undefined types. | ||||
24 | |||||
25 | Later, when you try to use the Undefined Type Constraint, autovivification will | ||||
26 | be attempted. | ||||
27 | |||||
28 | =head1 METHODS | ||||
29 | |||||
30 | =head2 new | ||||
31 | |||||
32 | Takes a full type name as argument and returns an instance of this | ||||
33 | class. | ||||
34 | |||||
35 | =cut | ||||
36 | |||||
37 | # spent 52µs within MooseX::Types::UndefinedType::new which was called 10 times, avg 5µs/call:
# 10 times (52µs+0s) by __TYPE__::SimpleDB::Class::Types::SdbArrayRefOfDateTime or __TYPE__::SimpleDB::Class::Types::SdbArrayRefOfInt or __TYPE__::SimpleDB::Class::Types::SdbArrayRefOfIntAsStr or __TYPE__::SimpleDB::Class::Types::SdbArrayRefOfStr or __TYPE__::SimpleDB::Class::Types::SdbDateTime or __TYPE__::SimpleDB::Class::Types::SdbHashRef or __TYPE__::SimpleDB::Class::Types::SdbInt or __TYPE__::SimpleDB::Class::Types::SdbIntAsStr or __TYPE__::SimpleDB::Class::Types::SdbMediumStr or __TYPE__::SimpleDB::Class::Types::SdbStr at line 403 of MooseX/Types.pm, avg 5µs/call | ||||
38 | 10 | 69µs | return bless { name => $_[1] }, $_[0]; | ||
39 | } | ||||
40 | |||||
41 | =head2 name | ||||
42 | |||||
43 | Returns the stored type name. | ||||
44 | |||||
45 | =cut | ||||
46 | |||||
47 | # spent 73µs within MooseX::Types::UndefinedType::name which was called 50 times, avg 1µs/call:
# 40 times (61µs+0s) by MooseX::Types::TypeDecorator::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/MooseX/Types/TypeDecorator.pm:20] at line 15 of MooseX/Types/TypeDecorator.pm, avg 2µs/call
# 10 times (12µs+0s) by MooseX::Types::UndefinedType::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/MooseX/Types/UndefinedType.pm:15] at line 15, avg 1µs/call | ||||
48 | 50 | 119µs | return $_[0]->{name}; | ||
49 | } | ||||
50 | |||||
51 | =head2 __autovivify | ||||
52 | |||||
53 | Try to see if the type constraint has yet been defined and if so create it. | ||||
54 | |||||
55 | =cut | ||||
56 | |||||
57 | sub __autovivify { | ||||
58 | my ($self) = @_; | ||||
59 | if(my $tc = $self->{instance}) { | ||||
60 | return $tc; | ||||
61 | } elsif( my $new_tc = Moose::Util::TypeConstraints::find_type_constraint($self->name)) { | ||||
62 | $self->{instance} = $new_tc; | ||||
63 | return $new_tc; | ||||
64 | } else { | ||||
65 | return; | ||||
66 | } | ||||
67 | } | ||||
68 | |||||
69 | =head2 AUTOLOAD | ||||
70 | |||||
71 | Try to autovivify and delegate | ||||
72 | |||||
73 | =cut | ||||
74 | |||||
75 | sub AUTOLOAD { | ||||
76 | my ($self, @args) = @_; | ||||
77 | my ($method) = our $AUTOLOAD =~ /([^:]+)$/; | ||||
78 | |||||
79 | if(my $type_constraint = $self->__autovivify) { | ||||
80 | return $type_constraint->$method(@args); | ||||
81 | } else { | ||||
82 | croak "Method '$method' is not supported for " . $self->name; | ||||
83 | } | ||||
84 | } | ||||
85 | |||||
86 | =head2 DESTROY | ||||
87 | |||||
88 | Moose::Meta::TypeConstraint::Parameterizable complains if this isn't here. TODO | ||||
89 | to find out why. | ||||
90 | |||||
91 | =cut | ||||
92 | |||||
93 | # spent 9µs within MooseX::Types::UndefinedType::DESTROY which was called 10 times, avg 930ns/call:
# once (4µs+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 120 of ../lib/SimpleDB/Class/Types.pm
# once (1µs+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 93 of ../lib/SimpleDB/Class/Types.pm
# once (600ns+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 103 of ../lib/SimpleDB/Class/Types.pm
# once (600ns+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 95 of ../lib/SimpleDB/Class/Types.pm
# once (600ns+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 108 of ../lib/SimpleDB/Class/Types.pm
# once (600ns+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 114 of ../lib/SimpleDB/Class/Types.pm
# once (600ns+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 112 of ../lib/SimpleDB/Class/Types.pm
# once (500ns+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 156 of ../lib/SimpleDB/Class/Types.pm
# once (500ns+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 98 of ../lib/SimpleDB/Class/Types.pm
# once (500ns+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 117 of ../lib/SimpleDB/Class/Types.pm | ||||
94 | 10 | 20µs | return; | ||
95 | } | ||||
96 | |||||
97 | =head1 SEE ALSO | ||||
98 | |||||
99 | L<MooseX::Types::Moose>, | ||||
100 | L<Moose::Util::TypeConstraints>, | ||||
101 | L<Moose::Meta::TypeConstraint>, | ||||
102 | L<Carp::Clan> | ||||
103 | |||||
104 | =head1 AUTHOR | ||||
105 | |||||
106 | See L<MooseX::Types/AUTHOR>. | ||||
107 | |||||
108 | =head1 LICENSE | ||||
109 | |||||
110 | This program is free software; you can redistribute it and/or modify | ||||
111 | it under the same terms as perl itself. | ||||
112 | |||||
113 | =cut | ||||
114 | |||||
115 | |||||
116 | 1 | 2µs | 1; |