File | /usr/local/lib/perl5/site_perl/5.10.1/MooseX/ClassAttribute/Role/Meta/Attribute.pm |
Statements Executed | 50 |
Statement Execution Time | 774µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 615µs | 3.72ms | BEGIN@6 | MooseX::ClassAttribute::Role::Meta::Attribute::
1 | 1 | 1 | 32µs | 260µs | _initialize | MooseX::ClassAttribute::Role::Meta::Attribute::
1 | 1 | 1 | 17µs | 24µs | BEGIN@3 | MooseX::ClassAttribute::Role::Meta::Attribute::
1 | 1 | 1 | 9µs | 1.51ms | BEGIN@8 | MooseX::ClassAttribute::Role::Meta::Attribute::
1 | 1 | 1 | 9µs | 28µs | BEGIN@4 | MooseX::ClassAttribute::Role::Meta::Attribute::
1 | 1 | 1 | 8µs | 112µs | BEGIN@138 | MooseX::ClassAttribute::Role::Meta::Attribute::
0 | 0 | 0 | 0s | 0s | __ANON__[:102] | MooseX::ClassAttribute::Role::Meta::Attribute::
0 | 0 | 0 | 0s | 0s | __ANON__[:112] | MooseX::ClassAttribute::Role::Meta::Attribute::
0 | 0 | 0 | 0s | 0s | __ANON__[:120] | MooseX::ClassAttribute::Role::Meta::Attribute::
0 | 0 | 0 | 0s | 0s | __ANON__[:128] | MooseX::ClassAttribute::Role::Meta::Attribute::
0 | 0 | 0 | 0s | 0s | __ANON__[:136] | MooseX::ClassAttribute::Role::Meta::Attribute::
0 | 0 | 0 | 0s | 0s | __ANON__[:18] | MooseX::ClassAttribute::Role::Meta::Attribute::
0 | 0 | 0 | 0s | 0s | __ANON__[:31] | MooseX::ClassAttribute::Role::Meta::Attribute::
0 | 0 | 0 | 0s | 0s | __ANON__[:43] | MooseX::ClassAttribute::Role::Meta::Attribute::
0 | 0 | 0 | 0s | 0s | __ANON__[:54] | MooseX::ClassAttribute::Role::Meta::Attribute::
0 | 0 | 0 | 0s | 0s | __ANON__[:84] | MooseX::ClassAttribute::Role::Meta::Attribute::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package MooseX::ClassAttribute::Role::Meta::Attribute; | ||||
2 | |||||
3 | 3 | 24µs | 2 | 31µs | # spent 24µs (17+7) within MooseX::ClassAttribute::Role::Meta::Attribute::BEGIN@3 which was called
# once (17µs+7µs) by MooseX::ClassAttribute::Role::Meta::Class::BEGIN@7 at line 3 # spent 24µs making 1 call to MooseX::ClassAttribute::Role::Meta::Attribute::BEGIN@3
# spent 7µs making 1 call to strict::import |
4 | 3 | 22µs | 2 | 48µs | # spent 28µs (9+19) within MooseX::ClassAttribute::Role::Meta::Attribute::BEGIN@4 which was called
# once (9µs+19µs) by MooseX::ClassAttribute::Role::Meta::Class::BEGIN@7 at line 4 # spent 28µs making 1 call to MooseX::ClassAttribute::Role::Meta::Attribute::BEGIN@4
# spent 19µs making 1 call to warnings::import |
5 | |||||
6 | 3 | 111µs | 1 | 3.72ms | # spent 3.72ms (615µs+3.11) within MooseX::ClassAttribute::Role::Meta::Attribute::BEGIN@6 which was called
# once (615µs+3.11ms) by MooseX::ClassAttribute::Role::Meta::Class::BEGIN@7 at line 6 # spent 3.72ms making 1 call to MooseX::ClassAttribute::Role::Meta::Attribute::BEGIN@6 |
7 | |||||
8 | 3 | 438µs | 2 | 3.01ms | # spent 1.51ms (9µs+1.50) within MooseX::ClassAttribute::Role::Meta::Attribute::BEGIN@8 which was called
# once (9µs+1.50ms) by MooseX::ClassAttribute::Role::Meta::Class::BEGIN@7 at line 8 # spent 1.51ms making 1 call to MooseX::ClassAttribute::Role::Meta::Attribute::BEGIN@8
# spent 1.50ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:389] |
9 | |||||
10 | # This is the worst role evar! Really, this should be a subclass, | ||||
11 | # because it overrides a lot of behavior. However, as a subclass it | ||||
12 | # won't cooperate with _other_ subclasses like | ||||
13 | # MX::AttributeHelpers::Base. | ||||
14 | |||||
15 | around 'accessor_metaclass' => sub | ||||
16 | { | ||||
17 | 1 | 3µs | return 'MooseX::ClassAttribute::Meta::Method::Accessor'; | ||
18 | 1 | 3µs | 1 | 56µs | }; # spent 56µs making 1 call to Moose::Role::around |
19 | |||||
20 | around '_process_options' => sub | ||||
21 | { | ||||
22 | 6 | 7µs | my $orig = shift; | ||
23 | my $class = shift; | ||||
24 | my $name = shift; | ||||
25 | my $options = shift; | ||||
26 | |||||
27 | confess 'A class attribute cannot be required' | ||||
28 | if $options->{required}; | ||||
29 | |||||
30 | return $class->$orig( $name, $options ); # spent 12µs making 1 call to Moose::Meta::Attribute::_process_options | ||||
31 | 1 | 3µs | 1 | 30µs | }; # spent 30µs making 1 call to Moose::Role::around |
32 | |||||
33 | around attach_to_class => sub | ||||
34 | { | ||||
35 | 5 | 24µs | my $orig = shift; | ||
36 | my $self = shift; | ||||
37 | my $meta = shift; | ||||
38 | |||||
39 | $self->$orig($meta); # spent 93µs making 1 call to Class::MOP::Attribute::attach_to_class | ||||
40 | |||||
41 | $self->_initialize($meta) # spent 260µs making 1 call to MooseX::ClassAttribute::Role::Meta::Attribute::_initialize
# spent 5µs making 1 call to Moose::Meta::Mixin::AttributeCore::is_lazy | ||||
42 | unless $self->is_lazy(); | ||||
43 | 1 | 2µs | 1 | 29µs | }; # spent 29µs making 1 call to Moose::Role::around |
44 | |||||
45 | around 'detach_from_class' => sub | ||||
46 | { | ||||
47 | my $orig = shift; | ||||
48 | my $self = shift; | ||||
49 | my $meta = shift; | ||||
50 | |||||
51 | $self->clear_value($meta); | ||||
52 | |||||
53 | $self->$orig($meta); | ||||
54 | 1 | 2µs | 1 | 29µs | }; # spent 29µs making 1 call to Moose::Role::around |
55 | |||||
56 | sub _initialize | ||||
57 | # spent 260µs (32+228) within MooseX::ClassAttribute::Role::Meta::Attribute::_initialize which was called
# once (32µs+228µs) by Class::MOP::Class:::around at line 41 | ||||
58 | 3 | 21µs | my $self = shift; | ||
59 | my $metaclass = shift; | ||||
60 | |||||
61 | if ( $self->has_default() ) # spent 170µs making 1 call to Class::MOP::Class::__ANON__::SERIAL::2::set_value
# spent 55µs making 1 call to Class::MOP::Class::__ANON__::SERIAL::2::default
# spent 3µs making 1 call to Class::MOP::Mixin::AttributeCore::has_default | ||||
62 | { | ||||
63 | $self->set_value( undef, $self->default() ); | ||||
64 | } | ||||
65 | elsif ( $self->has_builder() ) | ||||
66 | { | ||||
67 | $self->set_value( undef, $self->_call_builder( $metaclass->name() ) ); | ||||
68 | } | ||||
69 | } | ||||
70 | |||||
71 | around 'default' => sub | ||||
72 | { | ||||
73 | 4 | 20µs | my $orig = shift; | ||
74 | my $self = shift; | ||||
75 | |||||
76 | my $default = $self->$orig(); # spent 3µs making 1 call to Class::MOP::Mixin::AttributeCore::default | ||||
77 | |||||
78 | if ( $self->is_default_a_coderef() ) # spent 4µs making 1 call to Class::MOP::Attribute::associated_class
# spent 4µs making 1 call to SimpleDB::Class::__ANON__[../lib/SimpleDB/Class.pm:341]
# spent 4µs making 1 call to Class::MOP::Mixin::AttributeCore::is_default_a_coderef | ||||
79 | { | ||||
80 | return $default->( $self->associated_class() ); | ||||
81 | } | ||||
82 | |||||
83 | return $default; | ||||
84 | 1 | 2µs | 1 | 28µs | }; # spent 28µs making 1 call to Moose::Role::around |
85 | |||||
86 | around '_call_builder' => sub | ||||
87 | { | ||||
88 | shift; | ||||
89 | my $self = shift; | ||||
90 | my $class = shift; | ||||
91 | |||||
92 | my $builder = $self->builder(); | ||||
93 | |||||
94 | return $class->$builder() | ||||
95 | if $class->can( $self->builder ); | ||||
96 | |||||
97 | confess( "$class does not support builder method '" | ||||
98 | . $self->builder | ||||
99 | . "' for attribute '" | ||||
100 | . $self->name | ||||
101 | . "'" ); | ||||
102 | 1 | 2µs | 1 | 29µs | }; # spent 29µs making 1 call to Moose::Role::around |
103 | |||||
104 | around 'set_value' => sub | ||||
105 | { | ||||
106 | 5 | 21µs | shift; | ||
107 | my $self = shift; | ||||
108 | shift; # ignoring instance or class name | ||||
109 | my $value = shift; | ||||
110 | |||||
111 | $self->associated_class()->set_class_attribute_value( $self->name() => $value ); # spent 131µs making 1 call to Class::MOP::Class::__ANON__::SERIAL::1::set_class_attribute_value
# spent 2µs making 1 call to Class::MOP::Attribute::associated_class
# spent 1µs making 1 call to Class::MOP::Mixin::AttributeCore::name | ||||
112 | 1 | 2µs | 1 | 28µs | }; # spent 28µs making 1 call to Moose::Role::around |
113 | |||||
114 | around 'get_value' => sub | ||||
115 | { | ||||
116 | shift; | ||||
117 | my $self = shift; | ||||
118 | |||||
119 | return $self->associated_class()->get_class_attribute_value( $self->name() ); | ||||
120 | 1 | 2µs | 1 | 30µs | }; # spent 30µs making 1 call to Moose::Role::around |
121 | |||||
122 | around 'has_value' => sub | ||||
123 | { | ||||
124 | shift; | ||||
125 | my $self = shift; | ||||
126 | |||||
127 | return $self->associated_class()->has_class_attribute_value( $self->name() ); | ||||
128 | 1 | 2µs | 1 | 29µs | }; # spent 29µs making 1 call to Moose::Role::around |
129 | |||||
130 | around 'clear_value' => sub | ||||
131 | { | ||||
132 | shift; | ||||
133 | my $self = shift; | ||||
134 | |||||
135 | return $self->associated_class()->clear_class_attribute_value( $self->name() ); | ||||
136 | 1 | 2µs | 1 | 29µs | }; # spent 29µs making 1 call to Moose::Role::around |
137 | |||||
138 | 3 | 38µs | 2 | 216µs | # spent 112µs (8+104) within MooseX::ClassAttribute::Role::Meta::Attribute::BEGIN@138 which was called
# once (8µs+104µs) by MooseX::ClassAttribute::Role::Meta::Class::BEGIN@7 at line 138 # spent 112µs making 1 call to MooseX::ClassAttribute::Role::Meta::Attribute::BEGIN@138
# spent 104µs making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:478] |
139 | |||||
140 | 1 | 20µs | 1; | ||
141 | |||||
142 | __END__ | ||||
143 | |||||
144 | =pod | ||||
145 | |||||
146 | =head1 NAME | ||||
147 | |||||
148 | MooseX::ClassAttribute::Role::Meta::Attribute - An attribute role for classes with class attributes | ||||
149 | |||||
150 | =head1 DESCRIPTION | ||||
151 | |||||
152 | This role modifies the behavior of class attributes in various | ||||
153 | ways. It really should be a subclass of C<Moose::Meta::Attribute>, but | ||||
154 | if it were then it couldn't be combined with other attribute | ||||
155 | metaclasses, like C<MooseX::AttributeHelpers>. | ||||
156 | |||||
157 | There are no new public methods implemented by this role. All it does | ||||
158 | is change the behavior of a number of existing methods. | ||||
159 | |||||
160 | =head1 AUTHOR | ||||
161 | |||||
162 | Dave Rolsky, C<< <autarch@urth.org> >> | ||||
163 | |||||
164 | =head1 BUGS | ||||
165 | |||||
166 | See L<MooseX::ClassAttribute> for details. | ||||
167 | |||||
168 | =head1 COPYRIGHT & LICENSE | ||||
169 | |||||
170 | Copyright 2007-2008 Dave Rolsky, All Rights Reserved. | ||||
171 | |||||
172 | This program is free software; you can redistribute it and/or modify | ||||
173 | it under the same terms as Perl itself. | ||||
174 | |||||
175 | =cut | ||||
176 | |||||
177 |