← Index
Performance Profile   « block view • line view • sub view »
For /wise/base/deliv/dev/bin/getfix
  Run on Thu May 20 15:30:03 2010
Reported on Thu May 20 16:25:31 2010

File/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm
Statements Executed1724469
Total Time11.0747280002515 seconds

Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
63865924243.552243.55224Class::Accessor::Grouped::get_simple
8338515150.959371.53211Class::Accessor::Grouped::get_inherited
127110.010270.01027Class::Accessor::Grouped::make_group_accessor
98110.003630.01487Class::Accessor::Grouped::_mk_group_accessors
981390.001140.01601Class::Accessor::Grouped::mk_group_accessors
3511110.000330.00049Class::Accessor::Grouped::set_inherited
3314140.000210.00022Class::Accessor::Grouped::set_simple
29220.000170.00061Class::Accessor::Grouped::get_component_class
7118.6e-50.00014Class::Accessor::Grouped::get_super_paths
00000Class::Accessor::Grouped::BEGIN
00000Class::Accessor::Grouped::make_group_ro_accessor
00000Class::Accessor::Grouped::make_group_wo_accessor
00000Class::Accessor::Grouped::mk_group_ro_accessors
00000Class::Accessor::Grouped::mk_group_wo_accessors
00000Class::Accessor::Grouped::set_component_class

LineStmts.Exclusive
Time
Avg.Code
1package Class::Accessor::Grouped;
232.9e-59.7e-6use strict;
# spent 11µs making 1 call to strict::import
332.6e-58.7e-6use warnings;
# spent 35µs making 1 call to warnings::import
431.7e-55.7e-6use Carp ();
531.6e-55.3e-6use Class::Inspector ();
633.9e-51.3e-5use Scalar::Util ();
730.001200.00040use MRO::Compat;
# spent 4µs making 1 call to import
8
911.0e-61.0e-6our $VERSION = '0.08001';
10
11=head1 NAME
12
13Class::Accessor::Grouped - Lets you build groups of accessors
14
15=head1 SYNOPSIS
16
17=head1 DESCRIPTION
18
19This class lets you build groups of accessors that will call different
20getters and setters.
21
22=head1 METHODS
23
24=head2 mk_group_accessors
25
26=over 4
27
28=item Arguments: $group, @fieldspec
29
30Returns: none
31
32=back
33
34Creates a set of accessors in a given group.
35
36$group is the name of the accessor group for the generated accessors; they
37will call get_$group($field) on get and set_$group($field, $value) on set.
38
39If you want to mimic Class::Accessor's mk_accessors $group has to be 'simple'
40to tell Class::Accessor::Grouped to use its own get_simple and set_simple
41methods.
42
43@fieldspec is a list of field/accessor names; if a fieldspec is a scalar
44this is used as both field and accessor name, if a listref it is expected to
45be of the form [ $accessor, $field ].
46
47=cut
48
49
# spent 16.0ms (1.14+14.9) within Class::Accessor::Grouped::mk_group_accessors which was called 98 times, avg 163µs/call: # 73 times (624µs+8.75ms) by DBIx::Class::Row::register_column at line 748 of /wise/base/static/lib/perl5/site_perl/5.10.0/DBIx/Class/Row.pm, avg 128µs/call # 14 times (264µs+1.89ms) by DBIx::Class::mk_classaccessor at line 17 of /wise/base/static/lib/perl5/site_perl/5.10.0/DBIx/Class.pm, avg 154µs/call # once (32µs+1.29ms) at line 14 of /wise/base/static/lib/perl5/site_perl/5.10.0/DBIx/Class/Storage/DBI.pm # once (28µs+1.15ms) at line 13 of /wise/base/static/lib/perl5/site_perl/5.10.0/DBIx/Class/ResultSource.pm # once (23µs+350µs) at line 12 of /wise/base/static/lib/perl5/site_perl/5.10.0/DBIx/Class/Storage.pm # once (23µs+276µs) at line 8 of /wise/base/static/lib/perl5/site_perl/5.10.0/DBIx/Class/Storage/Statistics.pm # once (31µs+230µs) at line 15 of /wise/base/static/lib/perl5/site_perl/5.10.0/DBIx/Class/ResultSourceHandle.pm # once (25µs+228µs) at line 17 of /wise/base/static/lib/perl5/site_perl/5.10.0/DBIx/Class/ResultSet.pm # once (13µs+196µs) at line 18 of /wise/base/static/lib/perl5/site_perl/5.10.0/DBIx/Class/ResultSource.pm # once (30µs+132µs) at line 28 of /wise/base/static/lib/perl5/site_perl/5.10.0/DBIx/Class/ResultSourceProxy.pm # once (22µs+135µs) at line 11 of /wise/base/static/lib/perl5/site_perl/5.10.0/DBIx/Class/Row.pm # once (19µs+132µs) at line 13 of /wise/base/static/lib/perl5/site_perl/5.10.0/DBIx/Class/Storage.pm # once (11µs+108µs) at line 22 of /wise/base/static/lib/perl5/site_perl/5.10.0/DBIx/Class/Storage/DBI.pm
sub mk_group_accessors {
502940.001083.7e-6 my ($self, $group, @fields) = @_;
51
52 $self->_mk_group_accessors('make_group_accessor', $group, @fields);
# spent 14.9ms making 98 calls to Class::Accessor::Grouped::_mk_group_accessors, avg 152µs/call
53 return;
54}
55
56
57{
5842.8e-57.0e-6 no strict 'refs';
# spent 19µs making 1 call to strict::unimport
5930.000600.00020 no warnings 'redefine';
# spent 18µs making 1 call to warnings::unimport
60
61
# spent 14.9ms (3.63+11.2) within Class::Accessor::Grouped::_mk_group_accessors which was called 98 times, avg 152µs/call: # 98 times (3.63ms+11.2ms) by Class::Accessor::Grouped::mk_group_accessors at line 52, avg 152µs/call
sub _mk_group_accessors {
623920.001965.0e-6 my($self, $maker, $group, @fields) = @_;
63 my $class = Scalar::Util::blessed $self || $self;
# spent 379µs making 98 calls to Scalar::Util::blessed, avg 4µs/call
64
65 # So we don't have to do lots of lookups inside the loop.
66 $maker = $self->can($maker) unless ref $maker;
# spent 590µs making 98 calls to UNIVERSAL::can, avg 6µs/call
67
68 foreach my $field (@fields) {
698890.002733.1e-6 if( $field eq 'DESTROY' ) {
70 Carp::carp("Having a data accessor named DESTROY in ".
71 "'$class' is unwise.");
72 }
73
74 my $name = $field;
75
76 ($name, $field) = @$field if ref $field;
77
78 my $accessor = $self->$maker($group, $field);
# spent 10.3ms making 127 calls to Class::Accessor::Grouped::make_group_accessor, avg 81µs/call
79 my $alias = "_${name}_accessor";
80
81 *{$class."\:\:$name"} = $accessor;
82 #unless defined &{$class."\:\:$field"}
83
84 *{$class."\:\:$alias"} = $accessor;
85 #unless defined &{$class."\:\:$alias"}
86 }
87 }
88}
89
90=head2 mk_group_ro_accessors
91
92=over 4
93
94=item Arguments: $group, @fieldspec
95
96Returns: none
97
98=back
99
100Creates a set of read only accessors in a given group. Identical to
101<L:/mk_group_accessors> but accessors will throw an error if passed a value
102rather than setting the value.
103
104=cut
105
106sub mk_group_ro_accessors {
107 my($self, $group, @fields) = @_;
108
109 $self->_mk_group_accessors('make_group_ro_accessor', $group, @fields);
110}
111
112=head2 mk_group_wo_accessors
113
114=over 4
115
116=item Arguments: $group, @fieldspec
117
118Returns: none
119
120=back
121
122Creates a set of write only accessors in a given group. Identical to
123<L:/mk_group_accessors> but accessors will throw an error if not passed a
124value rather than getting the value.
125
126=cut
127
128sub mk_group_wo_accessors {
129 my($self, $group, @fields) = @_;
130
131 $self->_mk_group_accessors('make_group_wo_accessor', $group, @fields);
132}
133
134=head2 make_group_accessor
135
136=over 4
137
138=item Arguments: $group, $field
139
140Returns: $sub (\CODE)
141
142=back
143
144Returns a single accessor in a given group; called by mk_group_accessors
145for each entry in @fieldspec.
146
147=cut
148
149
# spent 10.3ms within Class::Accessor::Grouped::make_group_accessor which was called 127 times, avg 81µs/call: # 127 times (10.3ms+0) by Class::Accessor::Grouped::_mk_group_accessors at line 78, avg 81µs/call
sub make_group_accessor {
1505080.008901.8e-5 my ($class, $group, $field) = @_;
151
152 my $set = "set_$group";
153 my $get = "get_$group";
154
155 # eval for faster fastiness
15617.503907.50390 return eval "sub {
# spent 5.81s making 624103 calls to DBIx::Class::Row::get_column, avg 9µs/call # spent 3.55s making 638659 calls to Class::Accessor::Grouped::get_simple, avg 6µs/call # spent 1.53s making 83351 calls to Class::Accessor::Grouped::get_inherited, avg 18µs/call # spent 613µs making 29 calls to Class::Accessor::Grouped::get_component_class, avg 21µs/call # spent 381µs making 29 calls to Class::Accessor::Grouped::set_inherited, avg 13µs/call # spent 374µs making 5 calls to DBIx::Class::ResultSourceProxy::get_inherited_ro_instance, avg 75µs/call # spent 222µs making 33 calls to Class::Accessor::Grouped::set_simple, avg 7µs/call
157 if(\@_ > 1) {
158 return shift->$set('$field', \@_);
159 }
160 else {
161 return shift->$get('$field');
162 }
163 };"
164}
165
166=head2 make_group_ro_accessor
167
168=over 4
169
170=item Arguments: $group, $field
171
172Returns: $sub (\CODE)
173
174=back
175
176Returns a single read-only accessor in a given group; called by
177mk_group_ro_accessors for each entry in @fieldspec.
178
179=cut
180
181sub make_group_ro_accessor {
182 my($class, $group, $field) = @_;
183
184 my $get = "get_$group";
185
186 return eval "sub {
187 if(\@_ > 1) {
188 my \$caller = caller;
189 Carp::croak(\"'\$caller' cannot alter the value of '$field' on \".
190 \"objects of class '$class'\");
191 }
192 else {
193 return shift->$get('$field');
194 }
195 };"
196}
197
198=head2 make_group_wo_accessor
199
200=over 4
201
202=item Arguments: $group, $field
203
204Returns: $sub (\CODE)
205
206=back
207
208Returns a single write-only accessor in a given group; called by
209mk_group_wo_accessors for each entry in @fieldspec.
210
211=cut
212
213sub make_group_wo_accessor {
214 my($class, $group, $field) = @_;
215
216 my $set = "set_$group";
217
218 return eval "sub {
219 unless (\@_ > 1) {
220 my \$caller = caller;
221 Carp::croak(\"'\$caller' cannot access the value of '$field' on \".
222 \"objects of class '$class'\");
223 }
224 else {
225 return shift->$set('$field', \@_);
226 }
227 };"
228}
229
230=head2 get_simple
231
232=over 4
233
234=item Arguments: $field
235
236Returns: $value
237
238=back
239
240Simple getter for hash-based objects which returns the value for the field
241name passed as an argument.
242
243=cut
244
245
# spent 3.55s within Class::Accessor::Grouped::get_simple which was called 638659 times, avg 6µs/call: # 166450 times (890ms+0) at line 6 of (eval 214)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 5µs/call # 110960 times (595ms+0) at line 6 of (eval 217)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 5µs/call # 55541 times (317ms+0) at line 6 of (eval 61)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 6µs/call # 55541 times (313ms+0) at line 6 of (eval 62)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 6µs/call # 55535 times (318ms+0) at line 6 of (eval 64)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 6µs/call # 55489 times (309ms+0) at line 6 of (eval 99)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 6µs/call # 55482 times (302ms+0) at line 6 of (eval 104)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 5µs/call # 55476 times (350ms+0) at line 6 of (eval 63)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 6µs/call # 28116 times (157ms+0) at line 6 of (eval 94)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 6µs/call # 24 times (145µs+0) at line 6 of (eval 215)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 6µs/call # 10 times (60µs+0) at line 6 of (eval 93)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 6µs/call # 8 times (75µs+0) at line 6 of (eval 205)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 9µs/call # 7 times (45µs+0) at line 6 of (eval 97)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 6µs/call # 4 times (26µs+0) at line 6 of (eval 219)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 7µs/call # 4 times (24µs+0) at line 6 of (eval 101)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 6µs/call # 4 times (22µs+0) at line 6 of (eval 96)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 6µs/call # once (12µs+0) at line 6 of (eval 223)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156 # once (10µs+0) at line 6 of (eval 220)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156 # once (9µs+0) at line 6 of (eval 212)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156 # once (9µs+0) at line 6 of (eval 224)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156 # once (9µs+0) at line 6 of (eval 216)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156 # once (8µs+0) at line 6 of (eval 218)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156 # once (8µs+0) at line 6 of (eval 95)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156 # once (7µs+0) at line 6 of (eval 213)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156
sub get_simple {
24612773182.208331.7e-6 my ($self, $get) = @_;
247 return $self->{$get};
248 return $_[0]->{$_[1]};
249}
250
251=head2 set_simple
252
253=over 4
254
255=item Arguments: $field, $new_value
256
257Returns: $new_value
258
259=back
260
261Simple setter for hash-based objects which sets and then returns the value
262for the field name passed as an argument.
263
264=cut
265
266
# spent 222µs (214+8) within Class::Accessor::Grouped::set_simple which was called 33 times, avg 7µs/call: # 10 times (45µs+0) at line 2 of (eval 99)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 5µs/call # 4 times (23µs+0) at line 2 of (eval 95)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 6µs/call # 4 times (18µs+0) at line 2 of (eval 96)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 5µs/call # 2 times (17µs+0) at line 2 of (eval 214)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 8µs/call # 2 times (11µs+0) at line 2 of (eval 216)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 6µs/call # 2 times (11µs+0) at line 2 of (eval 215)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 6µs/call # 2 times (10µs+0) at line 2 of (eval 101)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 5µs/call # once (37µs+8µs) at line 2 of (eval 224)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156 # once (9µs+0) at line 2 of (eval 217)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156 # once (8µs+0) at line 2 of (eval 207)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156 # once (7µs+0) at line 2 of (eval 222)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156 # once (7µs+0) at line 2 of (eval 212)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156 # once (6µs+0) at line 2 of (eval 213)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156 # once (5µs+0) at line 2 of (eval 206)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156
sub set_simple {
267339.5e-52.9e-6 return $_[0]->{$_[1]} = $_[2];
# spent 8µs making 1 call to DBI::common::FETCH
268}
269
270
271=head2 get_inherited
272
273=over 4
274
275=item Arguments: $field
276
277Returns: $value
278
279=back
280
281Simple getter for Classes and hash-based objects which returns the value for
282the field name passed as an argument. This behaves much like
283L<Class::Data::Accessor> where the field can be set in a base class,
284inherited and changed in subclasses, and inherited and changed for object
285instances.
286
287=cut
288
289
# spent 1.53s (959ms+573ms) within Class::Accessor::Grouped::get_inherited which was called 83385 times, avg 18µs/call: # 55560 times (562ms+389ms) at line 6 of (eval 49)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 17µs/call # 27745 times (395ms+183ms) at line 6 of (eval 132)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 21µs/call # 29 times (267µs+173µs) by Class::Accessor::Grouped::get_component_class at line 375, avg 15µs/call # 10 times (128µs+43µs) at line 6 of (eval 48)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 17µs/call # 6 times (78µs+29µs) at line 6 of (eval 112)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 18µs/call # 5 times (466µs+125µs) at line 6 of (eval 108)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 118µs/call # 5 times (324µs+17µs) by DBIx::Class::ResultSourceProxy::get_inherited_ro_instance at line 25 of /wise/base/static/lib/perl5/site_perl/5.10.0/DBIx/Class/ResultSourceProxy.pm, avg 68µs/call # 5 times (129µs+39µs) at line 6 of (eval 51)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 34µs/call # 4 times (122µs+30µs) at line 6 of (eval 208)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 38µs/call # 4 times (50µs+12µs) at line 6 of (eval 182)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 16µs/call # 4 times (50µs+11µs) at line 6 of (eval 187)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 15µs/call # 3 times (88µs+18µs) at line 6 of (eval 54)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 35µs/call # 3 times (33µs+9µs) at line 6 of (eval 192)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 14µs/call # once (57µs+32µs) at line 6 of (eval 225)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156 # once (38µs+7µs) by Class::Accessor::Grouped::__ANON__[(eval 0)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156]:8] at line 6 of (eval 50)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156
sub get_inherited {
2901946180.638723.3e-6 my $class;
291
2922500550.705402.8e-6 if (Scalar::Util::blessed $_[0]) {
# spent 299ms making 83385 calls to Scalar::Util::blessed, avg 4µs/call
293 my $reftype = Scalar::Util::reftype $_[0];
# spent 273ms making 83335 calls to Scalar::Util::reftype, avg 3µs/call
294 $class = ref $_[0];
295
296 if ($reftype eq 'HASH' && exists $_[0]->{$_[1]}) {
297 return $_[0]->{$_[1]};
298 } elsif ($reftype ne 'HASH') {
299 Carp::croak('Cannot get inherited value on an object instance that is not hash-based');
300 };
301 } else {
302 $class = $_[0];
303 };
304
30530.000186.1e-5 no strict 'refs';
# spent 21µs making 1 call to strict::unimport
306 return ${$class.'::__cag_'.$_[1]} if defined(${$class.'::__cag_'.$_[1]});
307
308 if (!@{$class.'::__cag_supers'}) {
# spent 140µs making 7 calls to Class::Accessor::Grouped::get_super_paths, avg 20µs/call
309 @{$class.'::__cag_supers'} = $_[0]->get_super_paths;
310 };
311
312 foreach (@{$class.'::__cag_supers'}) {
3132260.000572.5e-6 return ${$_.'::__cag_'.$_[1]} if defined(${$_.'::__cag_'.$_[1]});
314 };
315
316 return undef;
317}
318
319=head2 set_inherited
320
321=over 4
322
323=item Arguments: $field, $new_value
324
325Returns: $new_value
326
327=back
328
329Simple setter for Classes and hash-based objects which sets and then returns
330the value for the field name passed as an argument. When called on a hash-based
331object it will set the appropriate hash key value. When called on a class, it
332will set a class level variable.
333
334B<Note:>: This method will die if you try to set an object variable on a non
335hash-based object.
336
337=cut
338
339
# spent 486µs (334+152) within Class::Accessor::Grouped::set_inherited which was called 35 times, avg 14µs/call: # 10 times (75µs+43µs) at line 2 of (eval 49)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 12µs/call # 10 times (76µs+39µs) at line 2 of (eval 48)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 11µs/call # 6 times (83µs+22µs) by DBIx::Class::mk_classaccessor at line 18 of /wise/base/static/lib/perl5/site_perl/5.10.0/DBIx/Class.pm, avg 18µs/call # 2 times (25µs+8µs) at line 2 of (eval 208)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 16µs/call # once (12µs+11µs) at line 2 of (eval 132)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156 # once (9µs+9µs) at line 2 of (eval 51)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156 # once (13µs+4µs) at line 2 of (eval 182)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156 # once (11µs+4µs) at line 2 of (eval 187)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156 # once (10µs+4µs) at line 2 of (eval 192)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156 # once (10µs+4µs) at line 2 of (eval 225)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156 # once (10µs+4µs) at line 2 of (eval 112)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156
sub set_inherited {
340590.000376.2e-6 if (Scalar::Util::blessed $_[0]) {
# spent 121µs making 35 calls to Scalar::Util::blessed, avg 3µs/call # spent 31µs making 11 calls to Scalar::Util::reftype, avg 3µs/call
341 if (Scalar::Util::reftype $_[0] eq 'HASH') {
342 return $_[0]->{$_[1]} = $_[2];
343 } else {
344 Carp::croak('Cannot set inherited value on an object instance that is not hash-based');
345 };
346 } else {
34730.000279.1e-5 no strict 'refs';
# spent 23µs making 1 call to strict::unimport
348
349 return ${$_[0].'::__cag_'.$_[1]} = $_[2];
350 };
351}
352
353=head2 get_component_class
354
355=over 4
356
357=item Arguments: $field
358
359Returns: $value
360
361=back
362
363Gets the value of the specified component class.
364
365 __PACKAGE__->mk_group_accessors('component_class' => 'result_class');
366
367 $self->result_class->method();
368
369 ## same as
370 $self->get_component_class('result_class')->method();
371
372=cut
373
374
# spent 613µs (173+440) within Class::Accessor::Grouped::get_component_class which was called 29 times, avg 21µs/call: # 26 times (144µs+392µs) at line 6 of (eval 106)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 21µs/call # 3 times (29µs+48µs) at line 6 of (eval 105)[/wise/base/static/lib/perl5/site_perl/5.10.0/Class/Accessor/Grouped.pm:156] at line 156, avg 26µs/call
sub get_component_class {
375290.000155.0e-6 return $_[0]->get_inherited($_[1]);
# spent 440µs making 29 calls to Class::Accessor::Grouped::get_inherited, avg 15µs/call
376};
377
378=head2 set_component_class
379
380=over 4
381
382=item Arguments: $field, $class
383
384Returns: $new_value
385
386=back
387
388Inherited accessor that automatically loads the specified class before setting
389it. This method will die if the specified class could not be loaded.
390
391 __PACKAGE__->mk_group_accessors('component_class' => 'result_class');
392 __PACKAGE__->result_class('MyClass');
393
394 $self->result_class->method();
395
396=cut
397
398sub set_component_class {
399 if ($_[2]) {
400 local $^W = 0;
401 if (Class::Inspector->installed($_[2]) && !Class::Inspector->loaded($_[2])) {
402 eval "use $_[2]";
403
404 Carp::croak("Could not load $_[1] '$_[2]': ", $@) if $@;
405 };
406 };
407
408 return $_[0]->set_inherited($_[1], $_[2]);
409};
410
411=head2 get_super_paths
412
413Returns a list of 'parent' or 'super' class names that the current class inherited from.
414
415=cut
416
417
# spent 140µs (86+54) within Class::Accessor::Grouped::get_super_paths which was called 7 times, avg 20µs/call: # 7 times (86µs+54µs) by Class::Accessor::Grouped::get_inherited at line 308, avg 20µs/call
sub get_super_paths {
418140.000128.9e-6 my $class = Scalar::Util::blessed $_[0] || $_[0];
# spent 23µs making 7 calls to Scalar::Util::blessed, avg 3µs/call
419
420 return @{mro::get_linear_isa($class)};
# spent 31µs making 7 calls to mro::get_linear_isa, avg 4µs/call
421};
422
42314.0e-64.0e-61;
424
425=head1 AUTHORS
426
427Matt S. Trout <mst@shadowcatsystems.co.uk>
428Christopher H. Laco <claco@chrislaco.com>
429
430=head1 LICENSE
431
432You may distribute this code under the same terms as Perl itself.
433
434=cut
435