Filename | /opt/perl-5.18.1/lib/site_perl/5.18.1/darwin-thread-multi-2level/Moose/Meta/Role/Attribute.pm |
Statements | Executed 21 statements in 883µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 12µs | 12µs | BEGIN@2 | Moose::Meta::Role::Attribute::
1 | 1 | 1 | 10µs | 37µs | BEGIN@13 | Moose::Meta::Role::Attribute::
1 | 1 | 1 | 9µs | 14µs | BEGIN@10 | Moose::Meta::Role::Attribute::
1 | 1 | 1 | 9µs | 42µs | BEGIN@12 | Moose::Meta::Role::Attribute::
1 | 1 | 1 | 9µs | 40µs | BEGIN@14 | Moose::Meta::Role::Attribute::
1 | 1 | 1 | 8µs | 141µs | BEGIN@16 | Moose::Meta::Role::Attribute::
1 | 1 | 1 | 8µs | 24µs | BEGIN@9 | Moose::Meta::Role::Attribute::
0 | 0 | 0 | 0s | 0s | __ANON__[:120] | Moose::Meta::Role::Attribute::
0 | 0 | 0 | 0s | 0s | attach_to_role | Moose::Meta::Role::Attribute::
0 | 0 | 0 | 0s | 0s | attribute_for_class | Moose::Meta::Role::Attribute::
0 | 0 | 0 | 0s | 0s | clone | Moose::Meta::Role::Attribute::
0 | 0 | 0 | 0s | 0s | is_same_as | Moose::Meta::Role::Attribute::
0 | 0 | 0 | 0s | 0s | new | Moose::Meta::Role::Attribute::
0 | 0 | 0 | 0s | 0s | original_role | Moose::Meta::Role::Attribute::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Moose::Meta::Role::Attribute; | ||||
2 | # spent 12µs within Moose::Meta::Role::Attribute::BEGIN@2 which was called:
# once (12µs+0s) by Moose::Meta::Role::BEGIN@19 at line 4 | ||||
3 | 1 | 7µs | $Moose::Meta::Role::Attribute::AUTHORITY = 'cpan:STEVAN'; | ||
4 | 1 | 41µs | 1 | 12µs | } # spent 12µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@2 |
5 | { | ||||
6 | 2 | 1µs | $Moose::Meta::Role::Attribute::VERSION = '2.1005'; | ||
7 | } | ||||
8 | |||||
9 | 2 | 38µs | 2 | 40µs | # spent 24µs (8+16) within Moose::Meta::Role::Attribute::BEGIN@9 which was called:
# once (8µs+16µs) by Moose::Meta::Role::BEGIN@19 at line 9 # spent 24µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@9
# spent 16µs making 1 call to strict::import |
10 | 2 | 33µs | 2 | 19µs | # spent 14µs (9+5) within Moose::Meta::Role::Attribute::BEGIN@10 which was called:
# once (9µs+5µs) by Moose::Meta::Role::BEGIN@19 at line 10 # spent 14µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@10
# spent 5µs making 1 call to warnings::import |
11 | |||||
12 | 2 | 39µs | 2 | 75µs | # spent 42µs (9+33) within Moose::Meta::Role::Attribute::BEGIN@12 which was called:
# once (9µs+33µs) by Moose::Meta::Role::BEGIN@19 at line 12 # spent 42µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@12
# spent 33µs making 1 call to Exporter::import |
13 | 2 | 35µs | 2 | 65µs | # spent 37µs (10+27) within Moose::Meta::Role::Attribute::BEGIN@13 which was called:
# once (10µs+27µs) by Moose::Meta::Role::BEGIN@19 at line 13 # spent 37µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@13
# spent 28µs making 1 call to Exporter::import |
14 | 2 | 35µs | 2 | 70µs | # spent 40µs (9+31) within Moose::Meta::Role::Attribute::BEGIN@14 which was called:
# once (9µs+31µs) by Moose::Meta::Role::BEGIN@19 at line 14 # spent 40µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@14
# spent 31µs making 1 call to Exporter::import |
15 | |||||
16 | 2 | 616µs | 2 | 274µs | # spent 141µs (8+133) within Moose::Meta::Role::Attribute::BEGIN@16 which was called:
# once (8µs+133µs) by Moose::Meta::Role::BEGIN@19 at line 16 # spent 141µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@16
# spent 133µs making 1 call to base::import |
17 | |||||
18 | 1 | 11µs | 3 | 919µs | __PACKAGE__->meta->add_attribute( # spent 512µs making 1 call to Class::MOP::Mixin::meta
# spent 400µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 7µs making 1 call to Class::MOP::_definition_context |
19 | 'metaclass' => ( | ||||
20 | reader => 'metaclass', | ||||
21 | Class::MOP::_definition_context(), | ||||
22 | ) | ||||
23 | ); | ||||
24 | |||||
25 | 1 | 4µs | 3 | 399µs | __PACKAGE__->meta->add_attribute( # spent 380µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 13µs making 1 call to Class::MOP::Mixin::meta
# spent 7µs making 1 call to Class::MOP::_definition_context |
26 | 'associated_role' => ( | ||||
27 | reader => 'associated_role', | ||||
28 | Class::MOP::_definition_context(), | ||||
29 | ) | ||||
30 | ); | ||||
31 | |||||
32 | 1 | 4µs | 3 | 392µs | __PACKAGE__->meta->add_attribute( # spent 373µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 12µs making 1 call to Class::MOP::Mixin::meta
# spent 7µs making 1 call to Class::MOP::_definition_context |
33 | '_original_role' => ( | ||||
34 | reader => '_original_role', | ||||
35 | Class::MOP::_definition_context(), | ||||
36 | ) | ||||
37 | ); | ||||
38 | |||||
39 | 1 | 4µs | 3 | 392µs | __PACKAGE__->meta->add_attribute( # spent 372µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 13µs making 1 call to Class::MOP::Mixin::meta
# spent 7µs making 1 call to Class::MOP::_definition_context |
40 | 'is' => ( | ||||
41 | reader => 'is', | ||||
42 | Class::MOP::_definition_context(), | ||||
43 | ) | ||||
44 | ); | ||||
45 | |||||
46 | 1 | 4µs | 3 | 394µs | __PACKAGE__->meta->add_attribute( # spent 375µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 12µs making 1 call to Class::MOP::Mixin::meta
# spent 7µs making 1 call to Class::MOP::_definition_context |
47 | 'original_options' => ( | ||||
48 | reader => 'original_options', | ||||
49 | Class::MOP::_definition_context(), | ||||
50 | ) | ||||
51 | ); | ||||
52 | |||||
53 | sub new { | ||||
54 | my ( $class, $name, %options ) = @_; | ||||
55 | |||||
56 | (defined $name) | ||||
57 | || confess "You must provide a name for the attribute"; | ||||
58 | |||||
59 | my $role = delete $options{_original_role}; | ||||
60 | |||||
61 | return bless { | ||||
62 | name => $name, | ||||
63 | original_options => \%options, | ||||
64 | _original_role => $role, | ||||
65 | %options, | ||||
66 | }, $class; | ||||
67 | } | ||||
68 | |||||
69 | sub attach_to_role { | ||||
70 | my ( $self, $role ) = @_; | ||||
71 | |||||
72 | ( blessed($role) && $role->isa('Moose::Meta::Role') ) | ||||
73 | || confess | ||||
74 | "You must pass a Moose::Meta::Role instance (or a subclass)"; | ||||
75 | |||||
76 | weaken( $self->{'associated_role'} = $role ); | ||||
77 | } | ||||
78 | |||||
79 | sub original_role { | ||||
80 | my $self = shift; | ||||
81 | |||||
82 | return $self->_original_role || $self->associated_role; | ||||
83 | } | ||||
84 | |||||
85 | sub attribute_for_class { | ||||
86 | my $self = shift; | ||||
87 | |||||
88 | my $metaclass = $self->original_role->applied_attribute_metaclass; | ||||
89 | |||||
90 | return $metaclass->interpolate_class_and_new( | ||||
91 | $self->name => %{ $self->original_options } ); | ||||
92 | } | ||||
93 | |||||
94 | sub clone { | ||||
95 | my $self = shift; | ||||
96 | |||||
97 | my $role = $self->original_role; | ||||
98 | |||||
99 | return ( ref $self )->new( | ||||
100 | $self->name, | ||||
101 | %{ $self->original_options }, | ||||
102 | _original_role => $role, | ||||
103 | ); | ||||
104 | } | ||||
105 | |||||
106 | sub is_same_as { | ||||
107 | my $self = shift; | ||||
108 | my $attr = shift; | ||||
109 | |||||
110 | my $self_options = $self->original_options; | ||||
111 | my $other_options = $attr->original_options; | ||||
112 | |||||
113 | return 0 | ||||
114 | unless ( join q{|}, sort keys %{$self_options} ) eq ( join q{|}, sort keys %{$other_options} ); | ||||
115 | |||||
116 | for my $key ( keys %{$self_options} ) { | ||||
117 | return 0 if defined $self_options->{$key} && ! defined $other_options->{$key}; | ||||
118 | return 0 if ! defined $self_options->{$key} && defined $other_options->{$key}; | ||||
119 | |||||
120 | next if all { ! defined } $self_options->{$key}, $other_options->{$key}; | ||||
121 | |||||
122 | return 0 unless $self_options->{$key} eq $other_options->{$key}; | ||||
123 | } | ||||
124 | |||||
125 | return 1; | ||||
126 | } | ||||
127 | |||||
128 | 1 | 11µs | 1; | ||
129 | |||||
130 | # ABSTRACT: The Moose attribute metaclass for Roles | ||||
131 | |||||
132 | __END__ |