Filename | /Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/TypeCoercion/Union.pm |
Statements | Executed 14 statements in 293µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 10µs | 10µs | BEGIN@3 | Moose::Meta::TypeCoercion::Union::
1 | 1 | 1 | 6µs | 26µs | BEGIN@14 | Moose::Meta::TypeCoercion::Union::
1 | 1 | 1 | 6µs | 9µs | BEGIN@11 | Moose::Meta::TypeCoercion::Union::
1 | 1 | 1 | 6µs | 54µs | BEGIN@16 | Moose::Meta::TypeCoercion::Union::
1 | 1 | 1 | 6µs | 18µs | BEGIN@10 | Moose::Meta::TypeCoercion::Union::
1 | 1 | 1 | 5µs | 335µ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 10µs within Moose::Meta::TypeCoercion::Union::BEGIN@3 which was called:
# once (10µs+0s) by Moose::Meta::TypeConstraint::Union::BEGIN@14 at line 5 | ||||
4 | 1 | 4µs | $Moose::Meta::TypeCoercion::Union::AUTHORITY = 'cpan:STEVAN'; | ||
5 | 1 | 26µs | 1 | 10µs | } # spent 10µs making 1 call to Moose::Meta::TypeCoercion::Union::BEGIN@3 |
6 | { | ||||
7 | 2 | 900ns | $Moose::Meta::TypeCoercion::Union::VERSION = '2.1005'; | ||
8 | } | ||||
9 | |||||
10 | 2 | 19µs | 2 | 30µs | # spent 18µs (6+12) within Moose::Meta::TypeCoercion::Union::BEGIN@10 which was called:
# once (6µs+12µs) by Moose::Meta::TypeConstraint::Union::BEGIN@14 at line 10 # spent 18µs making 1 call to Moose::Meta::TypeCoercion::Union::BEGIN@10
# spent 12µs making 1 call to strict::import |
11 | 2 | 21µs | 2 | 12µs | # spent 9µs (6+3) within Moose::Meta::TypeCoercion::Union::BEGIN@11 which was called:
# once (6µs+3µs) by Moose::Meta::TypeConstraint::Union::BEGIN@14 at line 11 # spent 9µs making 1 call to Moose::Meta::TypeCoercion::Union::BEGIN@11
# spent 3µs making 1 call to warnings::import |
12 | 2 | 24µs | 2 | 665µs | # spent 335µs (5+330) within Moose::Meta::TypeCoercion::Union::BEGIN@12 which was called:
# once (5µs+330µs) by Moose::Meta::TypeConstraint::Union::BEGIN@14 at line 12 # spent 335µs making 1 call to Moose::Meta::TypeCoercion::Union::BEGIN@12
# spent 330µs making 1 call to metaclass::import |
13 | |||||
14 | 2 | 22µs | 2 | 46µs | # spent 26µs (6+20) within Moose::Meta::TypeCoercion::Union::BEGIN@14 which was called:
# once (6µs+20µs) by Moose::Meta::TypeConstraint::Union::BEGIN@14 at line 14 # spent 26µs making 1 call to Moose::Meta::TypeCoercion::Union::BEGIN@14
# spent 20µs making 1 call to Exporter::import |
15 | |||||
16 | 2 | 175µs | 2 | 102µs | # spent 54µs (6+48) within Moose::Meta::TypeCoercion::Union::BEGIN@16 which was called:
# once (6µs+48µs) by Moose::Meta::TypeConstraint::Union::BEGIN@14 at line 16 # spent 54µs making 1 call to Moose::Meta::TypeCoercion::Union::BEGIN@16
# spent 48µ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 | 2µs | 1; | ||
49 | |||||
50 | # ABSTRACT: The Moose Type Coercion metaclass for Unions | ||||
51 | |||||
52 | __END__ |