Filename | /opt/perl-5.18.1/lib/site_perl/5.18.1/darwin-thread-multi-2level/Moose/Meta/TypeCoercion/Union.pm |
Statements | Executed 14 statements in 480µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 13µs | 82µs | BEGIN@16 | Moose::Meta::TypeCoercion::Union::
1 | 1 | 1 | 12µs | 12µs | BEGIN@3 | Moose::Meta::TypeCoercion::Union::
1 | 1 | 1 | 10µs | 15µs | BEGIN@11 | Moose::Meta::TypeCoercion::Union::
1 | 1 | 1 | 9µs | 40µs | BEGIN@14 | Moose::Meta::TypeCoercion::Union::
1 | 1 | 1 | 9µs | 24µs | BEGIN@10 | Moose::Meta::TypeCoercion::Union::
1 | 1 | 1 | 8µs | 496µs | BEGIN@12 | Moose::Meta::TypeCoercion::Union::
0 | 0 | 0 | 0s | 0s | __ANON__[:37] | Moose::Meta::TypeCoercion::Union::
0 | 0 | 0 | 0s | 0s | add_type_coercions | Moose::Meta::TypeCoercion::Union::
0 | 0 | 0 | 0s | 0s | compile_type_coercion | Moose::Meta::TypeCoercion::Union::
0 | 0 | 0 | 0s | 0s | has_coercion_for_type | Moose::Meta::TypeCoercion::Union::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | |||||
2 | package Moose::Meta::TypeCoercion::Union; | ||||
3 | # spent 12µs within Moose::Meta::TypeCoercion::Union::BEGIN@3 which was called:
# once (12µs+0s) by Moose::Meta::TypeConstraint::Union::BEGIN@14 at line 5 | ||||
4 | 1 | 7µs | $Moose::Meta::TypeCoercion::Union::AUTHORITY = 'cpan:STEVAN'; | ||
5 | 1 | 47µs | 1 | 12µs | } # spent 12µs making 1 call to Moose::Meta::TypeCoercion::Union::BEGIN@3 |
6 | { | ||||
7 | 2 | 1µs | $Moose::Meta::TypeCoercion::Union::VERSION = '2.1005'; | ||
8 | } | ||||
9 | |||||
10 | 2 | 36µs | 2 | 40µs | # spent 24µs (9+15) within Moose::Meta::TypeCoercion::Union::BEGIN@10 which was called:
# once (9µs+15µs) by Moose::Meta::TypeConstraint::Union::BEGIN@14 at line 10 # spent 24µs making 1 call to Moose::Meta::TypeCoercion::Union::BEGIN@10
# spent 15µs making 1 call to strict::import |
11 | 2 | 30µs | 2 | 20µs | # spent 15µs (10+5) within Moose::Meta::TypeCoercion::Union::BEGIN@11 which was called:
# once (10µs+5µs) by Moose::Meta::TypeConstraint::Union::BEGIN@14 at line 11 # spent 15µs making 1 call to Moose::Meta::TypeCoercion::Union::BEGIN@11
# spent 5µs making 1 call to warnings::import |
12 | 2 | 38µs | 2 | 984µs | # spent 496µs (8+488) within Moose::Meta::TypeCoercion::Union::BEGIN@12 which was called:
# once (8µs+488µs) by Moose::Meta::TypeConstraint::Union::BEGIN@14 at line 12 # spent 496µs making 1 call to Moose::Meta::TypeCoercion::Union::BEGIN@12
# spent 488µs making 1 call to metaclass::import |
13 | |||||
14 | 2 | 47µs | 2 | 72µs | # spent 40µs (9+31) within Moose::Meta::TypeCoercion::Union::BEGIN@14 which was called:
# once (9µs+31µs) by Moose::Meta::TypeConstraint::Union::BEGIN@14 at line 14 # spent 40µs making 1 call to Moose::Meta::TypeCoercion::Union::BEGIN@14
# spent 31µs making 1 call to Exporter::import |
15 | |||||
16 | 2 | 270µs | 2 | 150µs | # spent 82µs (13+69) within Moose::Meta::TypeCoercion::Union::BEGIN@16 which was called:
# once (13µs+69µs) by Moose::Meta::TypeConstraint::Union::BEGIN@14 at line 16 # spent 82µs making 1 call to Moose::Meta::TypeCoercion::Union::BEGIN@16
# spent 69µs making 1 call to base::import |
17 | |||||
18 | sub compile_type_coercion { | ||||
19 | my $self = shift; | ||||
20 | my $type_constraint = $self->type_constraint; | ||||
21 | |||||
22 | (blessed $type_constraint && $type_constraint->isa('Moose::Meta::TypeConstraint::Union')) | ||||
23 | || Moose->throw_error("You can only create a Moose::Meta::TypeCoercion::Union for a " . | ||||
24 | "Moose::Meta::TypeConstraint::Union, not a $type_constraint"); | ||||
25 | |||||
26 | $self->_compiled_type_coercion( | ||||
27 | sub { | ||||
28 | my $value = shift; | ||||
29 | |||||
30 | foreach my $type ( grep { $_->has_coercion } | ||||
31 | @{ $type_constraint->type_constraints } ) { | ||||
32 | my $temp = $type->coerce($value); | ||||
33 | return $temp if $type_constraint->check($temp); | ||||
34 | } | ||||
35 | |||||
36 | return $value; | ||||
37 | } | ||||
38 | ); | ||||
39 | } | ||||
40 | |||||
41 | sub has_coercion_for_type { 0 } | ||||
42 | |||||
43 | sub add_type_coercions { | ||||
44 | require Moose; | ||||
45 | Moose->throw_error("Cannot add additional type coercions to Union types"); | ||||
46 | } | ||||
47 | |||||
48 | 1 | 4µs | 1; | ||
49 | |||||
50 | # ABSTRACT: The Moose Type Coercion metaclass for Unions | ||||
51 | |||||
52 | __END__ |