| Filename | /usr/local/lib/perl/5.10.1/Mouse/Meta/Attribute.pm |
| Statements | Executed 1619 statements in 8.61ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 1.92ms | 1.98ms | Mouse::Meta::Attribute::BEGIN@6 |
| 45 | 1 | 1 | 1.15ms | 4.62ms | Mouse::Meta::Attribute::install_accessors |
| 45 | 1 | 1 | 843µs | 2.29ms | Mouse::Meta::Attribute::new |
| 45 | 1 | 1 | 381µs | 1.31ms | Mouse::Meta::Attribute::_process_options (xsub) |
| 45 | 1 | 1 | 178µs | 178µs | Mouse::Meta::Attribute::interpolate_class |
| 49 | 1 | 1 | 153µs | 153µs | Mouse::Meta::Attribute::associate_method |
| 73 | 2 | 2 | 68µs | 68µs | Mouse::Meta::Attribute::name (xsub) |
| 45 | 1 | 1 | 46µs | 46µs | Mouse::Meta::Attribute::has_type_constraint (xsub) |
| 45 | 1 | 1 | 45µs | 45µs | Mouse::Meta::Attribute::accessor_metaclass (xsub) |
| 45 | 1 | 1 | 43µs | 43µs | Mouse::Meta::Attribute::has_trigger (xsub) |
| 45 | 1 | 1 | 42µs | 42µs | Mouse::Meta::Attribute::associated_class (xsub) |
| 45 | 1 | 1 | 37µs | 37µs | Mouse::Meta::Attribute::init_arg (xsub) |
| 45 | 1 | 1 | 36µs | 36µs | Mouse::Meta::Attribute::is_lazy (xsub) |
| 43 | 1 | 1 | 36µs | 36µs | Mouse::Meta::Attribute::should_coerce (xsub) |
| 43 | 1 | 1 | 35µs | 35µs | Mouse::Meta::Attribute::should_auto_deref (xsub) |
| 45 | 1 | 1 | 34µs | 34µs | Mouse::Meta::Attribute::has_builder (xsub) |
| 43 | 1 | 1 | 33µs | 33µs | Mouse::Meta::Attribute::type_constraint (xsub) |
| 45 | 1 | 1 | 33µs | 33µs | Mouse::Meta::Attribute::is_weak_ref (xsub) |
| 41 | 1 | 1 | 32µs | 32µs | Mouse::Meta::Attribute::has_default (xsub) |
| 45 | 1 | 1 | 31µs | 31µs | Mouse::Meta::Attribute::is_required (xsub) |
| 1 | 1 | 1 | 16µs | 64µs | Mouse::Meta::Attribute::BEGIN@2 |
| 12 | 1 | 1 | 9µs | 9µs | Mouse::Meta::Attribute::default (xsub) |
| 1 | 1 | 1 | 5µs | 5µs | Mouse::Meta::Attribute::BEGIN@4 |
| 1 | 1 | 1 | 800ns | 800ns | Mouse::Meta::Attribute::builder (xsub) |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Attribute::_canonicalize_handles |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Attribute::_find_delegate_metaclass |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Attribute::_get_accessor_method_ref |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Attribute::_make_delegation_method |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Attribute::_throw_type_constraint_error |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Attribute::clear_value |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Attribute::clone_and_inherit_options |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Attribute::get_read_method |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Attribute::get_read_method_ref |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Attribute::get_value |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Attribute::get_write_method |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Attribute::get_write_method_ref |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Attribute::has_read_method |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Attribute::has_value |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Attribute::has_write_method |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Attribute::illegal_options_for_inheritance |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Attribute::set_value |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Attribute::verify_against_type_constraint |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Mouse::Meta::Attribute; | ||||
| 2 | 3 | 35µs | 2 | 113µs | # spent 64µs (16+49) within Mouse::Meta::Attribute::BEGIN@2 which was called:
# once (16µs+49µs) by Mouse::BEGIN@16 at line 2 # spent 64µs making 1 call to Mouse::Meta::Attribute::BEGIN@2
# spent 49µs making 1 call to Mouse::Exporter::do_import |
| 3 | |||||
| 4 | 3 | 32µs | 1 | 5µs | # spent 5µs within Mouse::Meta::Attribute::BEGIN@4 which was called:
# once (5µs+0s) by Mouse::BEGIN@16 at line 4 # spent 5µs making 1 call to Mouse::Meta::Attribute::BEGIN@4 |
| 5 | |||||
| 6 | 3 | 2.24ms | 1 | 1.98ms | # spent 1.98ms (1.92+66µs) within Mouse::Meta::Attribute::BEGIN@6 which was called:
# once (1.92ms+66µs) by Mouse::BEGIN@16 at line 6 # spent 1.98ms making 1 call to Mouse::Meta::Attribute::BEGIN@6 |
| 7 | |||||
| 8 | 1 | 26µs | my %valid_options = map { $_ => undef } ( | ||
| 9 | 'accessor', | ||||
| 10 | 'auto_deref', | ||||
| 11 | 'builder', | ||||
| 12 | 'clearer', | ||||
| 13 | 'coerce', | ||||
| 14 | 'default', | ||||
| 15 | 'documentation', | ||||
| 16 | 'does', | ||||
| 17 | 'handles', | ||||
| 18 | 'init_arg', | ||||
| 19 | 'insertion_order', | ||||
| 20 | 'is', | ||||
| 21 | 'isa', | ||||
| 22 | 'lazy', | ||||
| 23 | 'lazy_build', | ||||
| 24 | 'name', | ||||
| 25 | 'predicate', | ||||
| 26 | 'reader', | ||||
| 27 | 'required', | ||||
| 28 | 'traits', | ||||
| 29 | 'trigger', | ||||
| 30 | 'type_constraint', | ||||
| 31 | 'weak_ref', | ||||
| 32 | 'writer', | ||||
| 33 | |||||
| 34 | # internally used | ||||
| 35 | 'associated_class', | ||||
| 36 | 'associated_methods', | ||||
| 37 | '__METACLASS__', | ||||
| 38 | |||||
| 39 | # Moose defines, but Mouse doesn't | ||||
| 40 | #'definition_context', | ||||
| 41 | #'initializer', | ||||
| 42 | |||||
| 43 | # special case for AttributeHelpers | ||||
| 44 | 'provides', | ||||
| 45 | 'curries', | ||||
| 46 | ); | ||||
| 47 | |||||
| 48 | 1 | 1µs | our @CARP_NOT = qw(Mouse::Meta::Class); | ||
| 49 | |||||
| 50 | # spent 2.29ms (843µs+1.45) within Mouse::Meta::Attribute::new which was called 45 times, avg 51µs/call:
# 45 times (843µs+1.45ms) by Mouse::Meta::Class::add_attribute at line 234 of Mouse/Meta/Class.pm, avg 51µs/call | ||||
| 51 | 45 | 25µs | my $class = shift; | ||
| 52 | 45 | 12µs | my $name = shift; | ||
| 53 | |||||
| 54 | 45 | 341µs | 45 | 135µs | my $args = $class->Mouse::Object::BUILDARGS(@_); # spent 135µs making 45 calls to Mouse::Object::BUILDARGS, avg 3µs/call |
| 55 | |||||
| 56 | 45 | 459µs | 88 | 2.24ms | $class->_process_options($name, $args); # spent 1.31ms making 45 calls to Mouse::Meta::Attribute::_process_options, avg 29µs/call
# spent 930µs making 43 calls to Mouse::Util::TypeConstraints::find_or_create_isa_type_constraint, avg 22µs/call |
| 57 | |||||
| 58 | 45 | 59µs | $args->{name} = $name; | ||
| 59 | |||||
| 60 | # check options | ||||
| 61 | # (1) known by core | ||||
| 62 | 45 | 200µs | my @bad = grep{ !exists $valid_options{$_} } keys %{$args}; | ||
| 63 | |||||
| 64 | # (2) known by subclasses | ||||
| 65 | 45 | 14µs | if(@bad && $class ne __PACKAGE__){ | ||
| 66 | my %valid_attrs = ( | ||||
| 67 | map { $_ => undef } | ||||
| 68 | grep { defined } | ||||
| 69 | map { $_->init_arg() } | ||||
| 70 | $class->meta->get_all_attributes() | ||||
| 71 | ); | ||||
| 72 | @bad = grep{ !exists $valid_attrs{$_} } @bad; | ||||
| 73 | } | ||||
| 74 | |||||
| 75 | # (3) bad options found | ||||
| 76 | 45 | 8µs | if(@bad){ | ||
| 77 | Carp::carp( | ||||
| 78 | "Found unknown argument(s) passed to '$name' attribute constructor in '$class': " | ||||
| 79 | . Mouse::Util::english_list(@bad)); | ||||
| 80 | } | ||||
| 81 | |||||
| 82 | 45 | 85µs | my $self = bless $args, $class; | ||
| 83 | 45 | 18µs | if($class ne __PACKAGE__){ | ||
| 84 | $class->meta->_initialize_object($self, $args); | ||||
| 85 | } | ||||
| 86 | 45 | 146µs | return $self; | ||
| 87 | } | ||||
| 88 | |||||
| 89 | sub has_read_method { $_[0]->has_reader || $_[0]->has_accessor } | ||||
| 90 | sub has_write_method { $_[0]->has_writer || $_[0]->has_accessor } | ||||
| 91 | |||||
| 92 | sub get_read_method { $_[0]->reader || $_[0]->accessor } | ||||
| 93 | sub get_write_method { $_[0]->writer || $_[0]->accessor } | ||||
| 94 | |||||
| 95 | sub get_read_method_ref{ | ||||
| 96 | my($self) = @_; | ||||
| 97 | return $self->{_mouse_cache_read_method_ref} | ||||
| 98 | ||= $self->_get_accessor_method_ref('get_read_method', '_generate_reader'); | ||||
| 99 | } | ||||
| 100 | |||||
| 101 | sub get_write_method_ref{ | ||||
| 102 | my($self) = @_; | ||||
| 103 | return $self->{_mouse_cache_write_method_ref} | ||||
| 104 | ||= $self->_get_accessor_method_ref('get_write_method', '_generate_writer'); | ||||
| 105 | } | ||||
| 106 | |||||
| 107 | # spent 178µs within Mouse::Meta::Attribute::interpolate_class which was called 45 times, avg 4µs/call:
# 45 times (178µs+0s) by Mouse::Meta::Class::add_attribute at line 231 of Mouse/Meta/Class.pm, avg 4µs/call | ||||
| 108 | 45 | 34µs | my($class, $args) = @_; | ||
| 109 | |||||
| 110 | 45 | 32µs | if(my $metaclass = delete $args->{metaclass}){ | ||
| 111 | $class = Mouse::Util::resolve_metaclass_alias( Attribute => $metaclass ); | ||||
| 112 | } | ||||
| 113 | |||||
| 114 | 45 | 8µs | my @traits; | ||
| 115 | 45 | 14µs | if(my $traits_ref = delete $args->{traits}){ | ||
| 116 | |||||
| 117 | for (my $i = 0; $i < @{$traits_ref}; $i++) { | ||||
| 118 | my $trait = Mouse::Util::resolve_metaclass_alias(Attribute => $traits_ref->[$i], trait => 1); | ||||
| 119 | |||||
| 120 | next if $class->does($trait); | ||||
| 121 | |||||
| 122 | push @traits, $trait; | ||||
| 123 | |||||
| 124 | # are there options? | ||||
| 125 | push @traits, $traits_ref->[++$i] | ||||
| 126 | if ref($traits_ref->[$i+1]); | ||||
| 127 | } | ||||
| 128 | |||||
| 129 | if (@traits) { | ||||
| 130 | $class = Mouse::Meta::Class->create_anon_class( | ||||
| 131 | superclasses => [ $class ], | ||||
| 132 | roles => \@traits, | ||||
| 133 | cache => 1, | ||||
| 134 | )->name; | ||||
| 135 | } | ||||
| 136 | } | ||||
| 137 | |||||
| 138 | 45 | 156µs | return( $class, @traits ); | ||
| 139 | } | ||||
| 140 | |||||
| 141 | sub verify_against_type_constraint { | ||||
| 142 | my ($self, $value) = @_; | ||||
| 143 | |||||
| 144 | my $type_constraint = $self->{type_constraint}; | ||||
| 145 | return 1 if !$type_constraint; | ||||
| 146 | return 1 if $type_constraint->check($value); | ||||
| 147 | |||||
| 148 | $self->_throw_type_constraint_error($value, $type_constraint); | ||||
| 149 | } | ||||
| 150 | |||||
| 151 | sub _throw_type_constraint_error { | ||||
| 152 | my($self, $value, $type) = @_; | ||||
| 153 | |||||
| 154 | $self->throw_error( | ||||
| 155 | sprintf q{Attribute (%s) does not pass the type constraint because: %s}, | ||||
| 156 | $self->name, | ||||
| 157 | $type->get_message($value), | ||||
| 158 | ); | ||||
| 159 | } | ||||
| 160 | |||||
| 161 | sub illegal_options_for_inheritance { | ||||
| 162 | return qw(reader writer accessor clearer predicate); | ||||
| 163 | } | ||||
| 164 | |||||
| 165 | sub clone_and_inherit_options{ | ||||
| 166 | my $self = shift; | ||||
| 167 | my $args = $self->Mouse::Object::BUILDARGS(@_); | ||||
| 168 | |||||
| 169 | foreach my $illegal($self->illegal_options_for_inheritance) { | ||||
| 170 | if(exists $args->{$illegal} and exists $self->{$illegal}) { | ||||
| 171 | $self->throw_error("Illegal inherited option: $illegal"); | ||||
| 172 | } | ||||
| 173 | } | ||||
| 174 | |||||
| 175 | foreach my $name(keys %{$self}){ | ||||
| 176 | if(!exists $args->{$name}){ | ||||
| 177 | $args->{$name} = $self->{$name}; # inherit from self | ||||
| 178 | } | ||||
| 179 | } | ||||
| 180 | |||||
| 181 | my($attribute_class, @traits) = ref($self)->interpolate_class($args); | ||||
| 182 | $args->{traits} = \@traits if @traits; | ||||
| 183 | |||||
| 184 | # remove temporary caches | ||||
| 185 | foreach my $attr(keys %{$args}){ | ||||
| 186 | if($attr =~ /\A _mouse_cache_/xms){ | ||||
| 187 | delete $args->{$attr}; | ||||
| 188 | } | ||||
| 189 | } | ||||
| 190 | |||||
| 191 | # remove default if lazy_build => 1 | ||||
| 192 | if($args->{lazy_build}) { | ||||
| 193 | delete $args->{default}; | ||||
| 194 | } | ||||
| 195 | |||||
| 196 | return $attribute_class->new($self->name, $args); | ||||
| 197 | } | ||||
| 198 | |||||
| 199 | |||||
| 200 | sub _get_accessor_method_ref { | ||||
| 201 | my($self, $type, $generator) = @_; | ||||
| 202 | |||||
| 203 | my $metaclass = $self->associated_class | ||||
| 204 | || $self->throw_error('No asocciated class for ' . $self->name); | ||||
| 205 | |||||
| 206 | my $accessor = $self->$type(); | ||||
| 207 | if($accessor){ | ||||
| 208 | return $metaclass->get_method_body($accessor); | ||||
| 209 | } | ||||
| 210 | else{ | ||||
| 211 | return $self->accessor_metaclass->$generator($self, $metaclass); | ||||
| 212 | } | ||||
| 213 | } | ||||
| 214 | |||||
| 215 | sub set_value { | ||||
| 216 | my($self, $object, $value) = @_; | ||||
| 217 | return $self->get_write_method_ref()->($object, $value); | ||||
| 218 | } | ||||
| 219 | |||||
| 220 | sub get_value { | ||||
| 221 | my($self, $object) = @_; | ||||
| 222 | return $self->get_read_method_ref()->($object); | ||||
| 223 | } | ||||
| 224 | |||||
| 225 | sub has_value { | ||||
| 226 | my($self, $object) = @_; | ||||
| 227 | my $accessor_ref = $self->{_mouse_cache_predicate_ref} | ||||
| 228 | ||= $self->_get_accessor_method_ref('predicate', '_generate_predicate'); | ||||
| 229 | |||||
| 230 | return $accessor_ref->($object); | ||||
| 231 | } | ||||
| 232 | |||||
| 233 | sub clear_value { | ||||
| 234 | my($self, $object) = @_; | ||||
| 235 | my $accessor_ref = $self->{_mouse_cache_crealer_ref} | ||||
| 236 | ||= $self->_get_accessor_method_ref('clearer', '_generate_clearer'); | ||||
| 237 | |||||
| 238 | return $accessor_ref->($object); | ||||
| 239 | } | ||||
| 240 | |||||
| 241 | # spent 153µs within Mouse::Meta::Attribute::associate_method which was called 49 times, avg 3µs/call:
# 49 times (153µs+0s) by Mouse::Meta::Attribute::install_accessors at line 266, avg 3µs/call | ||||
| 242 | #my($attribute, $method_name) = @_; | ||||
| 243 | 49 | 29µs | my($attribute) = @_; | ||
| 244 | 49 | 42µs | $attribute->{associated_methods}++; | ||
| 245 | 49 | 138µs | return; | ||
| 246 | } | ||||
| 247 | |||||
| 248 | # spent 4.62ms (1.15+3.47) within Mouse::Meta::Attribute::install_accessors which was called 45 times, avg 103µs/call:
# 45 times (1.15ms+3.47ms) by Mouse::Meta::Class::add_attribute at line 241 of Mouse/Meta/Class.pm, avg 103µs/call | ||||
| 249 | 45 | 25µs | my($attribute) = @_; | ||
| 250 | |||||
| 251 | 45 | 163µs | 45 | 42µs | my $metaclass = $attribute->associated_class; # spent 42µs making 45 calls to Mouse::Meta::Attribute::associated_class, avg 927ns/call |
| 252 | 45 | 162µs | 45 | 45µs | my $accessor_class = $attribute->accessor_metaclass; # spent 45µs making 45 calls to Mouse::Meta::Attribute::accessor_metaclass, avg 998ns/call |
| 253 | |||||
| 254 | 45 | 44µs | foreach my $type(qw(accessor reader writer predicate clearer)){ | ||
| 255 | 225 | 173µs | if(exists $attribute->{$type}){ | ||
| 256 | 49 | 30µs | my $generator = '_generate_' . $type; | ||
| 257 | 49 | 3.05ms | 583 | 3.29ms | my $code = $accessor_class->$generator($attribute, $metaclass); # spent 1.61ms making 26 calls to Mouse::Meta::Method::Accessor::XS::_generate_reader, avg 62µs/call
# spent 1.20ms making 19 calls to Mouse::Meta::Method::Accessor::XS::_generate_accessor, avg 63µs/call
# spent 46µs making 45 calls to Mouse::Meta::Attribute::has_type_constraint, avg 1µs/call
# spent 44µs making 49 calls to Mouse::Meta::Attribute::name, avg 904ns/call
# spent 43µs making 45 calls to Mouse::Meta::Attribute::has_trigger, avg 956ns/call
# spent 37µs making 45 calls to Mouse::Meta::Attribute::init_arg, avg 822ns/call
# spent 36µs making 45 calls to Mouse::Meta::Attribute::is_lazy, avg 798ns/call
# spent 36µs making 43 calls to Mouse::Meta::Attribute::should_coerce, avg 828ns/call
# spent 35µs making 43 calls to Mouse::Meta::Attribute::should_auto_deref, avg 812ns/call
# spent 34µs making 45 calls to Mouse::Meta::Attribute::has_builder, avg 760ns/call
# spent 33µs making 43 calls to Mouse::Meta::Attribute::type_constraint, avg 774ns/call
# spent 33µs making 45 calls to Mouse::Meta::Attribute::is_weak_ref, avg 736ns/call
# spent 32µs making 41 calls to Mouse::Meta::Attribute::has_default, avg 768ns/call
# spent 31µs making 45 calls to Mouse::Meta::Attribute::is_required, avg 698ns/call
# spent 19µs making 2 calls to Mouse::Meta::Method::Accessor::XS::_generate_predicate, avg 9µs/call
# spent 18µs making 2 calls to Mouse::Meta::Method::Accessor::XS::_generate_clearer, avg 9µs/call |
| 258 | 49 | 32µs | my $name = $attribute->{$type}; | ||
| 259 | # TODO: do something for compatibility | ||||
| 260 | # if( $metaclass->name->can($name) ) { | ||||
| 261 | # my $t = $metaclass->has_method($name) ? 'method' : 'function'; | ||||
| 262 | # Carp::cluck("You are overwriting a locally defined $t" | ||||
| 263 | # . " ($name) with an accessor"); | ||||
| 264 | # } | ||||
| 265 | 49 | 538µs | 49 | 379µs | $metaclass->add_method($name => $code); # spent 379µs making 49 calls to Mouse::Meta::Module::add_method, avg 8µs/call |
| 266 | 49 | 111µs | 49 | 153µs | $attribute->associate_method($name); # spent 153µs making 49 calls to Mouse::Meta::Attribute::associate_method, avg 3µs/call |
| 267 | } | ||||
| 268 | } | ||||
| 269 | |||||
| 270 | # install delegation | ||||
| 271 | 45 | 15µs | if(exists $attribute->{handles}){ | ||
| 272 | my %handles = $attribute->_canonicalize_handles(); | ||||
| 273 | while(my($handle, $method_to_call) = each %handles){ | ||||
| 274 | next if Mouse::Object->can($handle); | ||||
| 275 | |||||
| 276 | if($metaclass->has_method($handle)) { | ||||
| 277 | $attribute->throw_error("You cannot overwrite a locally defined method ($handle) with a delegation"); | ||||
| 278 | } | ||||
| 279 | |||||
| 280 | $metaclass->add_method($handle => | ||||
| 281 | $attribute->_make_delegation_method( | ||||
| 282 | $handle, $method_to_call)); | ||||
| 283 | |||||
| 284 | $attribute->associate_method($handle); | ||||
| 285 | } | ||||
| 286 | } | ||||
| 287 | |||||
| 288 | 45 | 110µs | return; | ||
| 289 | } | ||||
| 290 | |||||
| 291 | sub delegation_metaclass() { ## no critic | ||||
| 292 | 'Mouse::Meta::Method::Delegation' | ||||
| 293 | } | ||||
| 294 | |||||
| 295 | sub _canonicalize_handles { | ||||
| 296 | my($self) = @_; | ||||
| 297 | my $handles = $self->{handles}; | ||||
| 298 | |||||
| 299 | my $handle_type = ref $handles; | ||||
| 300 | if ($handle_type eq 'HASH') { | ||||
| 301 | return %$handles; | ||||
| 302 | } | ||||
| 303 | elsif ($handle_type eq 'ARRAY') { | ||||
| 304 | return map { $_ => $_ } @$handles; | ||||
| 305 | } | ||||
| 306 | elsif ($handle_type eq 'Regexp') { | ||||
| 307 | my $meta = $self->_find_delegate_metaclass(); | ||||
| 308 | return map { $_ => $_ } | ||||
| 309 | grep { /$handles/ } | ||||
| 310 | Mouse::Util::is_a_metarole($meta) | ||||
| 311 | ? $meta->get_method_list | ||||
| 312 | : $meta->get_all_method_names; | ||||
| 313 | } | ||||
| 314 | elsif ($handle_type eq 'CODE') { | ||||
| 315 | return $handles->( $self, $self->_find_delegate_metaclass() ); | ||||
| 316 | } | ||||
| 317 | else { | ||||
| 318 | $self->throw_error("Unable to canonicalize the 'handles' option with $handles"); | ||||
| 319 | } | ||||
| 320 | } | ||||
| 321 | |||||
| 322 | sub _find_delegate_metaclass { | ||||
| 323 | my($self) = @_; | ||||
| 324 | my $meta; | ||||
| 325 | if($self->{isa}) { | ||||
| 326 | $meta = Mouse::Meta::Class->initialize("$self->{isa}"); | ||||
| 327 | } | ||||
| 328 | elsif($self->{does}) { | ||||
| 329 | $meta = Mouse::Util::get_metaclass_by_name("$self->{does}"); | ||||
| 330 | } | ||||
| 331 | defined($meta) or $self->throw_error( | ||||
| 332 | "Cannot find delegate metaclass for attribute " . $self->name); | ||||
| 333 | return $meta; | ||||
| 334 | } | ||||
| 335 | |||||
| 336 | |||||
| 337 | sub _make_delegation_method { | ||||
| 338 | my($self, $handle, $method_to_call) = @_; | ||||
| 339 | return Mouse::Util::load_class($self->delegation_metaclass) | ||||
| 340 | ->_generate_delegation($self, $handle, $method_to_call); | ||||
| 341 | } | ||||
| 342 | |||||
| 343 | 1 | 9µs | 1; | ||
| 344 | __END__ | ||||
# spent 1.31ms (381µs+930µs) within Mouse::Meta::Attribute::_process_options which was called 45 times, avg 29µs/call:
# 45 times (381µs+930µs) by Mouse::Meta::Attribute::new at line 56, avg 29µs/call | |||||
# spent 45µs within Mouse::Meta::Attribute::accessor_metaclass which was called 45 times, avg 998ns/call:
# 45 times (45µs+0s) by Mouse::Meta::Attribute::install_accessors at line 252, avg 998ns/call | |||||
# spent 42µs within Mouse::Meta::Attribute::associated_class which was called 45 times, avg 927ns/call:
# 45 times (42µs+0s) by Mouse::Meta::Attribute::install_accessors at line 251, avg 927ns/call | |||||
# spent 800ns within Mouse::Meta::Attribute::builder which was called:
# once (800ns+0s) by MongoDB::Collection::full_name at line 300 of MongoDB/Collection.pm | |||||
# spent 9µs within Mouse::Meta::Attribute::default which was called 12 times, avg 742ns/call:
# 12 times (9µs+0s) by Mouse::Object::new at line 13 of mongo_pain.pl, avg 742ns/call | |||||
# spent 34µs within Mouse::Meta::Attribute::has_builder which was called 45 times, avg 760ns/call:
# 45 times (34µs+0s) by Mouse::Meta::Method::Accessor::XS::_generate_accessor or Mouse::Meta::Method::Accessor::XS::_generate_reader at line 257, avg 760ns/call | |||||
# spent 32µs within Mouse::Meta::Attribute::has_default which was called 41 times, avg 768ns/call:
# 41 times (32µs+0s) by Mouse::Meta::Method::Accessor::XS::_generate_accessor or Mouse::Meta::Method::Accessor::XS::_generate_reader at line 257, avg 768ns/call | |||||
# spent 43µs within Mouse::Meta::Attribute::has_trigger which was called 45 times, avg 956ns/call:
# 45 times (43µs+0s) by Mouse::Meta::Method::Accessor::XS::_generate_accessor or Mouse::Meta::Method::Accessor::XS::_generate_reader at line 257, avg 956ns/call | |||||
# spent 46µs within Mouse::Meta::Attribute::has_type_constraint which was called 45 times, avg 1µs/call:
# 45 times (46µs+0s) by Mouse::Meta::Method::Accessor::XS::_generate_accessor or Mouse::Meta::Method::Accessor::XS::_generate_reader at line 257, avg 1µs/call | |||||
# spent 37µs within Mouse::Meta::Attribute::init_arg which was called 45 times, avg 822ns/call:
# 45 times (37µs+0s) by Mouse::Meta::Method::Accessor::XS::_generate_accessor or Mouse::Meta::Method::Accessor::XS::_generate_reader at line 257, avg 822ns/call | |||||
# spent 36µs within Mouse::Meta::Attribute::is_lazy which was called 45 times, avg 798ns/call:
# 45 times (36µs+0s) by Mouse::Meta::Method::Accessor::XS::_generate_accessor or Mouse::Meta::Method::Accessor::XS::_generate_reader at line 257, avg 798ns/call | |||||
# spent 31µs within Mouse::Meta::Attribute::is_required which was called 45 times, avg 698ns/call:
# 45 times (31µs+0s) by Mouse::Meta::Method::Accessor::XS::_generate_accessor or Mouse::Meta::Method::Accessor::XS::_generate_reader at line 257, avg 698ns/call | |||||
# spent 33µs within Mouse::Meta::Attribute::is_weak_ref which was called 45 times, avg 736ns/call:
# 45 times (33µs+0s) by Mouse::Meta::Method::Accessor::XS::_generate_accessor or Mouse::Meta::Method::Accessor::XS::_generate_reader at line 257, avg 736ns/call | |||||
# spent 68µs within Mouse::Meta::Attribute::name which was called 73 times, avg 929ns/call:
# 49 times (44µs+0s) by Mouse::Meta::Method::Accessor::XS::_generate_accessor or Mouse::Meta::Method::Accessor::XS::_generate_clearer or Mouse::Meta::Method::Accessor::XS::_generate_predicate or Mouse::Meta::Method::Accessor::XS::_generate_reader at line 257, avg 904ns/call
# 24 times (24µs+0s) by Mouse::Meta::Class::_calculate_all_attributes at line 261 of Mouse/Meta/Class.pm, avg 979ns/call | |||||
# spent 35µs within Mouse::Meta::Attribute::should_auto_deref which was called 43 times, avg 812ns/call:
# 43 times (35µs+0s) by Mouse::Meta::Method::Accessor::XS::_generate_accessor or Mouse::Meta::Method::Accessor::XS::_generate_reader at line 257, avg 812ns/call | |||||
# spent 36µs within Mouse::Meta::Attribute::should_coerce which was called 43 times, avg 828ns/call:
# 43 times (36µs+0s) by Mouse::Meta::Method::Accessor::XS::_generate_accessor or Mouse::Meta::Method::Accessor::XS::_generate_reader at line 257, avg 828ns/call | |||||
# spent 33µs within Mouse::Meta::Attribute::type_constraint which was called 43 times, avg 774ns/call:
# 43 times (33µs+0s) by Mouse::Meta::Method::Accessor::XS::_generate_accessor or Mouse::Meta::Method::Accessor::XS::_generate_reader at line 257, avg 774ns/call |