| Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Meta/Class.pm |
| Statements | Executed 955 statements in 7.47ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 2.10ms | 3.01ms | Moose::Meta::Class::BEGIN@28 |
| 63 | 6 | 2 | 948µs | 16.2ms | Moose::Meta::Class::superclasses (recurses: max depth 2, inclusive time 2.38ms) |
| 20 | 2 | 1 | 585µs | 843µs | Moose::Meta::Class::_base_metaclasses |
| 1 | 1 | 1 | 585µs | 820µs | Moose::Meta::Class::BEGIN@26 |
| 1 | 1 | 1 | 386µs | 576µs | Moose::Meta::Class::BEGIN@24 |
| 1 | 1 | 1 | 343µs | 1.92ms | Moose::Meta::Class::BEGIN@23 |
| 1 | 1 | 1 | 338µs | 597µs | Moose::Meta::Class::BEGIN@25 |
| 1 | 1 | 1 | 310µs | 433µs | Moose::Meta::Class::BEGIN@22 |
| 1 | 1 | 1 | 305µs | 2.92ms | Moose::Meta::Class::BEGIN@21 |
| 9 | 1 | 1 | 250µs | 1.07ms | Moose::Meta::Class::_inline_create_error |
| 8 | 2 | 2 | 240µs | 17.8ms | Moose::Meta::Class::add_attribute |
| 1 | 1 | 1 | 237µs | 377µs | Moose::Meta::Class::BEGIN@27 |
| 9 | 3 | 3 | 235µs | 8.97ms | Moose::Meta::Class::initialize |
| 4 | 1 | 1 | 223µs | 1.28ms | Moose::Meta::Class::excludes_role |
| 120 | 1 | 1 | 185µs | 185µs | Moose::Meta::Class::CORE:subst (opcode) |
| 3 | 1 | 1 | 130µs | 1.15ms | Moose::Meta::Class::does_role |
| 9 | 1 | 1 | 80µs | 1.18ms | Moose::Meta::Class::_inline_throw_error |
| 1 | 1 | 1 | 74µs | 8.91ms | Moose::Meta::Class::create |
| 6 | 1 | 1 | 68µs | 2.49ms | Moose::Meta::Class::_process_attribute |
| 6 | 1 | 1 | 66µs | 2.42ms | Moose::Meta::Class::_process_new_attribute |
| 3 | 1 | 1 | 66µs | 4.07ms | Moose::Meta::Class::new_object (recurses: max depth 1, inclusive time 216µs) |
| 4 | 1 | 1 | 60µs | 84µs | Moose::Meta::Class::add_role |
| 4 | 1 | 1 | 59µs | 85µs | Moose::Meta::Class::add_role_application |
| 3 | 1 | 1 | 46µs | 188µs | Moose::Meta::Class::_call_all_triggers |
| 9 | 1 | 1 | 32µs | 32µs | Moose::Meta::Class::__ANON__[:37] |
| 9 | 1 | 1 | 30µs | 30µs | Moose::Meta::Class::_inline_raise_error |
| 9 | 1 | 1 | 21µs | 21µs | Moose::Meta::Class::__ANON__[:43] |
| 9 | 1 | 1 | 18µs | 18µs | Moose::Meta::Class::_meta_method_class |
| 1 | 1 | 1 | 9µs | 9µs | Moose::Meta::Class::BEGIN@3 |
| 1 | 1 | 1 | 9µs | 53µs | Moose::Meta::Class::BEGIN@13 |
| 1 | 1 | 1 | 8µs | 13µs | Moose::Meta::Class::BEGIN@16 |
| 1 | 1 | 1 | 8µs | 95µs | Moose::Meta::Class::BEGIN@31 |
| 1 | 1 | 1 | 8µs | 8µs | Moose::Meta::Class::BEGIN@29 |
| 1 | 1 | 1 | 8µs | 30µs | Moose::Meta::Class::BEGIN@19 |
| 1 | 1 | 1 | 7µs | 26µs | Moose::Meta::Class::BEGIN@17 |
| 1 | 1 | 1 | 7µs | 41µs | Moose::Meta::Class::BEGIN@18 |
| 1 | 1 | 1 | 7µs | 30µs | Moose::Meta::Class::BEGIN@15 |
| 1 | 1 | 1 | 7µs | 9µs | Moose::Meta::Class::BEGIN@10 |
| 1 | 1 | 1 | 6µs | 15µs | Moose::Meta::Class::BEGIN@11 |
| 6 | 1 | 1 | 6µs | 6µs | Moose::Meta::Class::CORE:match (opcode) |
| 1 | 1 | 1 | 4µs | 4µs | Moose::Meta::Class::BEGIN@14 |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::__ANON__[:125] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::__ANON__[:533] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_anon_cache_key |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_anon_package_prefix |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_eval_environment |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_find_next_method_by_name_which_is_not_overridden |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_fix_class_metaclass_incompatibility |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_fix_single_metaclass_incompatibility |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_fixup_attributes_after_rebless |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_generate_fallback_constructor |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_immutable_options |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_inline_BUILDALL |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_inline_BUILDARGS |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_inline_check_required_attr |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_inline_extra_init |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_inline_init_attr_from_constructor |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_inline_init_attr_from_default |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_inline_params |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_inline_slot_initializer |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_inline_triggers |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_process_inherited_attribute |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_replace_self |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_restore_metaobjects_from |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::add_augment_method_modifier |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::add_override_method_modifier |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::calculate_all_roles |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::calculate_all_roles_with_inheritance |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::create_error |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::raise_error |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::reinitialize |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::role_applications |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::throw_error |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | |||||
| 2 | package Moose::Meta::Class; | ||||
| 3 | # spent 9µs within Moose::Meta::Class::BEGIN@3 which was called:
# once (9µs+0s) by Moose::BEGIN@28 at line 5 | ||||
| 4 | 1 | 4µs | $Moose::Meta::Class::AUTHORITY = 'cpan:STEVAN'; | ||
| 5 | 1 | 21µs | 1 | 9µs | } # spent 9µs making 1 call to Moose::Meta::Class::BEGIN@3 |
| 6 | { | ||||
| 7 | 2 | 2µs | $Moose::Meta::Class::VERSION = '2.0602'; | ||
| 8 | } | ||||
| 9 | |||||
| 10 | 3 | 16µs | 2 | 11µs | # spent 9µs (7+2) within Moose::Meta::Class::BEGIN@10 which was called:
# once (7µs+2µs) by Moose::BEGIN@28 at line 10 # spent 9µs making 1 call to Moose::Meta::Class::BEGIN@10
# spent 2µs making 1 call to strict::import |
| 11 | 3 | 19µs | 2 | 23µs | # spent 15µs (6+8) within Moose::Meta::Class::BEGIN@11 which was called:
# once (6µs+8µs) by Moose::BEGIN@28 at line 11 # spent 15µs making 1 call to Moose::Meta::Class::BEGIN@11
# spent 8µs making 1 call to warnings::import |
| 12 | |||||
| 13 | 3 | 20µs | 2 | 97µs | # spent 53µs (9+44) within Moose::Meta::Class::BEGIN@13 which was called:
# once (9µs+44µs) by Moose::BEGIN@28 at line 13 # spent 53µs making 1 call to Moose::Meta::Class::BEGIN@13
# spent 44µs making 1 call to Exporter::import |
| 14 | 3 | 20µs | 1 | 4µs | # spent 4µs within Moose::Meta::Class::BEGIN@14 which was called:
# once (4µs+0s) by Moose::BEGIN@28 at line 14 # spent 4µs making 1 call to Moose::Meta::Class::BEGIN@14 |
| 15 | 3 | 17µs | 2 | 54µs | # spent 30µs (7+24) within Moose::Meta::Class::BEGIN@15 which was called:
# once (7µs+24µs) by Moose::BEGIN@28 at line 15 # spent 30µs making 1 call to Moose::Meta::Class::BEGIN@15
# spent 24µs making 1 call to Exporter::import |
| 16 | 3 | 20µs | 2 | 19µs | # spent 13µs (8+5) within Moose::Meta::Class::BEGIN@16 which was called:
# once (8µs+5µs) by Moose::BEGIN@28 at line 16 # spent 13µs making 1 call to Moose::Meta::Class::BEGIN@16
# spent 5µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:284] |
| 17 | 3 | 20µs | 2 | 46µs | # spent 26µs (7+20) within Moose::Meta::Class::BEGIN@17 which was called:
# once (7µs+20µs) by Moose::BEGIN@28 at line 17 # spent 26µs making 1 call to Moose::Meta::Class::BEGIN@17
# spent 20µs making 1 call to Exporter::import |
| 18 | 3 | 24µs | 2 | 76µs | # spent 41µs (7+34) within Moose::Meta::Class::BEGIN@18 which was called:
# once (7µs+34µs) by Moose::BEGIN@28 at line 18 # spent 41µs making 1 call to Moose::Meta::Class::BEGIN@18
# spent 34µs making 1 call to Exporter::import |
| 19 | 3 | 18µs | 2 | 52µs | # spent 30µs (8+22) within Moose::Meta::Class::BEGIN@19 which was called:
# once (8µs+22µs) by Moose::BEGIN@28 at line 19 # spent 30µs making 1 call to Moose::Meta::Class::BEGIN@19
# spent 22µs making 1 call to Exporter::import |
| 20 | |||||
| 21 | 3 | 98µs | 1 | 2.92ms | # spent 2.92ms (305µs+2.62) within Moose::Meta::Class::BEGIN@21 which was called:
# once (305µs+2.62ms) by Moose::BEGIN@28 at line 21 # spent 2.92ms making 1 call to Moose::Meta::Class::BEGIN@21 |
| 22 | 3 | 109µs | 1 | 433µs | # spent 433µs (310+122) within Moose::Meta::Class::BEGIN@22 which was called:
# once (310µs+122µs) by Moose::BEGIN@28 at line 22 # spent 433µs making 1 call to Moose::Meta::Class::BEGIN@22 |
| 23 | 3 | 101µs | 1 | 1.92ms | # spent 1.92ms (343µs+1.58) within Moose::Meta::Class::BEGIN@23 which was called:
# once (343µs+1.58ms) by Moose::BEGIN@28 at line 23 # spent 1.92ms making 1 call to Moose::Meta::Class::BEGIN@23 |
| 24 | 3 | 127µs | 1 | 576µs | # spent 576µs (386+190) within Moose::Meta::Class::BEGIN@24 which was called:
# once (386µs+190µs) by Moose::BEGIN@28 at line 24 # spent 576µs making 1 call to Moose::Meta::Class::BEGIN@24 |
| 25 | 3 | 85µs | 1 | 597µs | # spent 597µs (338+259) within Moose::Meta::Class::BEGIN@25 which was called:
# once (338µs+259µs) by Moose::BEGIN@28 at line 25 # spent 597µs making 1 call to Moose::Meta::Class::BEGIN@25 |
| 26 | 3 | 81µs | 1 | 820µs | # spent 820µs (585+235) within Moose::Meta::Class::BEGIN@26 which was called:
# once (585µs+235µs) by Moose::BEGIN@28 at line 26 # spent 820µs making 1 call to Moose::Meta::Class::BEGIN@26 |
| 27 | 3 | 79µs | 1 | 377µs | # spent 377µs (237+140) within Moose::Meta::Class::BEGIN@27 which was called:
# once (237µs+140µs) by Moose::BEGIN@28 at line 27 # spent 377µs making 1 call to Moose::Meta::Class::BEGIN@27 |
| 28 | 3 | 91µs | 2 | 3.14ms | # spent 3.01ms (2.10+906µs) within Moose::Meta::Class::BEGIN@28 which was called:
# once (2.10ms+906µs) by Moose::BEGIN@28 at line 28 # spent 3.01ms making 1 call to Moose::Meta::Class::BEGIN@28
# spent 129µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756] |
| 29 | 3 | 23µs | 1 | 8µs | # spent 8µs within Moose::Meta::Class::BEGIN@29 which was called:
# once (8µs+0s) by Moose::BEGIN@28 at line 29 # spent 8µs making 1 call to Moose::Meta::Class::BEGIN@29 |
| 30 | |||||
| 31 | 3 | 3.01ms | 2 | 181µs | # spent 95µs (8+87) within Moose::Meta::Class::BEGIN@31 which was called:
# once (8µs+87µs) by Moose::BEGIN@28 at line 31 # spent 95µs making 1 call to Moose::Meta::Class::BEGIN@31
# spent 87µs making 1 call to base::import |
| 32 | |||||
| 33 | 1 | 5µs | 1 | 1.68ms | Class::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait'); # spent 1.68ms making 1 call to Class::MOP::MiniTrait::apply |
| 34 | |||||
| 35 | __PACKAGE__->meta->add_attribute('roles' => ( | ||||
| 36 | reader => 'roles', | ||||
| 37 | 9 | 41µs | # spent 32µs within Moose::Meta::Class::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Meta/Class.pm:37] which was called 9 times, avg 4µs/call:
# 9 times (32µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 45 of Class/MOP/Mixin/AttributeCore.pm, avg 4µs/call | ||
| 38 | 1 | 19µs | 3 | 618µs | Class::MOP::_definition_context(), # spent 595µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 12µs making 1 call to Class::MOP::Object::meta
# spent 11µs making 1 call to Class::MOP::_definition_context |
| 39 | )); | ||||
| 40 | |||||
| 41 | __PACKAGE__->meta->add_attribute('role_applications' => ( | ||||
| 42 | reader => '_get_role_applications', | ||||
| 43 | 9 | 30µs | # spent 21µs within Moose::Meta::Class::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Meta/Class.pm:43] which was called 9 times, avg 2µs/call:
# 9 times (21µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 45 of Class/MOP/Mixin/AttributeCore.pm, avg 2µs/call | ||
| 44 | 1 | 7µs | 3 | 297µs | Class::MOP::_definition_context(), # spent 280µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 11µs making 1 call to Class::MOP::Object::meta
# spent 5µs making 1 call to Class::MOP::_definition_context |
| 45 | )); | ||||
| 46 | |||||
| 47 | 1 | 7µs | 4 | 294µs | __PACKAGE__->meta->add_attribute( # spent 262µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 18µs making 1 call to Class::MOP::Attribute::new
# spent 10µs making 1 call to Class::MOP::Object::meta
# spent 4µs making 1 call to Class::MOP::_definition_context |
| 48 | Class::MOP::Attribute->new('immutable_trait' => ( | ||||
| 49 | accessor => "immutable_trait", | ||||
| 50 | default => 'Moose::Meta::Class::Immutable::Trait', | ||||
| 51 | Class::MOP::_definition_context(), | ||||
| 52 | )) | ||||
| 53 | ); | ||||
| 54 | |||||
| 55 | 1 | 5µs | 3 | 288µs | __PACKAGE__->meta->add_attribute('constructor_class' => ( # spent 273µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 10µs making 1 call to Class::MOP::Object::meta
# spent 5µs making 1 call to Class::MOP::_definition_context |
| 56 | accessor => 'constructor_class', | ||||
| 57 | default => 'Moose::Meta::Method::Constructor', | ||||
| 58 | Class::MOP::_definition_context(), | ||||
| 59 | )); | ||||
| 60 | |||||
| 61 | 1 | 4µs | 3 | 277µs | __PACKAGE__->meta->add_attribute('destructor_class' => ( # spent 263µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 10µs making 1 call to Class::MOP::Object::meta
# spent 5µs making 1 call to Class::MOP::_definition_context |
| 62 | accessor => 'destructor_class', | ||||
| 63 | default => 'Moose::Meta::Method::Destructor', | ||||
| 64 | Class::MOP::_definition_context(), | ||||
| 65 | )); | ||||
| 66 | |||||
| 67 | 1 | 4µs | 3 | 274µs | __PACKAGE__->meta->add_attribute('error_class' => ( # spent 260µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 10µs making 1 call to Class::MOP::Object::meta
# spent 4µs making 1 call to Class::MOP::_definition_context |
| 68 | accessor => 'error_class', | ||||
| 69 | default => 'Moose::Error::Default', | ||||
| 70 | Class::MOP::_definition_context(), | ||||
| 71 | )); | ||||
| 72 | |||||
| 73 | # spent 8.97ms (235µs+8.73) within Moose::Meta::Class::initialize which was called 9 times, avg 997µs/call:
# 7 times (161µs+5.81ms) by Moose::init_meta at line 196 of Moose.pm, avg 853µs/call
# once (39µs+1.91ms) by Class::MOP::Package::create at line 72 of Class/MOP/Package.pm
# once (35µs+1.02ms) by metaclass::import at line 48 of metaclass.pm | ||||
| 74 | 9 | 11µs | my $class = shift; | ||
| 75 | 9 | 15µs | my @args = @_; | ||
| 76 | 9 | 23µs | unshift @args, 'package' if @args % 2; | ||
| 77 | 9 | 17µs | my %opts = @args; | ||
| 78 | 9 | 16µs | my $package = delete $opts{package}; | ||
| 79 | 9 | 147µs | 18 | 8.73ms | return Class::MOP::get_metaclass_by_name($package) # spent 8.72ms making 9 calls to Class::MOP::Class::initialize, avg 969µs/call
# spent 16µs making 9 calls to Class::MOP::get_metaclass_by_name, avg 2µs/call |
| 80 | || $class->SUPER::initialize($package, | ||||
| 81 | 'attribute_metaclass' => 'Moose::Meta::Attribute', | ||||
| 82 | 'method_metaclass' => 'Moose::Meta::Method', | ||||
| 83 | 'instance_metaclass' => 'Moose::Meta::Instance', | ||||
| 84 | %opts, | ||||
| 85 | ); | ||||
| 86 | } | ||||
| 87 | |||||
| 88 | # spent 8.91ms (74µs+8.83) within Moose::Meta::Class::create which was called:
# once (74µs+8.83ms) by MooseX::Traits::Util::new_class_with_traits at line 67 of MooseX/Traits/Util.pm | ||||
| 89 | 1 | 1µs | my $class = shift; | ||
| 90 | 1 | 8µs | my @args = @_; | ||
| 91 | |||||
| 92 | 1 | 4µs | unshift @args, 'package' if @args % 2 == 1; | ||
| 93 | 1 | 7µs | my %options = @args; | ||
| 94 | |||||
| 95 | 1 | 3µs | (ref $options{roles} eq 'ARRAY') | ||
| 96 | || $class->throw_error("You must pass an ARRAY ref of roles", data => $options{roles}) | ||||
| 97 | if exists $options{roles}; | ||||
| 98 | |||||
| 99 | 1 | 3µs | my $package = delete $options{package}; | ||
| 100 | 1 | 2µs | my $roles = delete $options{roles}; | ||
| 101 | |||||
| 102 | 1 | 25µs | 1 | 6.36ms | my $new_meta = $class->SUPER::create($package, %options); # spent 6.36ms making 1 call to Class::MOP::Class::create |
| 103 | |||||
| 104 | 1 | 7µs | 1 | 2.47ms | if ($roles) { # spent 2.47ms making 1 call to Moose::Util::apply_all_roles |
| 105 | Moose::Util::apply_all_roles( $new_meta, @$roles ); | ||||
| 106 | } | ||||
| 107 | |||||
| 108 | 1 | 8µs | return $new_meta; | ||
| 109 | } | ||||
| 110 | |||||
| 111 | 9 | 29µs | # spent 18µs within Moose::Meta::Class::_meta_method_class which was called 9 times, avg 2µs/call:
# 9 times (18µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 33 of Class/MOP/Mixin/HasMethods.pm, avg 2µs/call | ||
| 112 | |||||
| 113 | sub _anon_package_prefix { 'Moose::Meta::Class::__ANON__::SERIAL::' } | ||||
| 114 | |||||
| 115 | sub _anon_cache_key { | ||||
| 116 | my $class = shift; | ||||
| 117 | my %options = @_; | ||||
| 118 | |||||
| 119 | my $superclass_key = join('|', | ||||
| 120 | map { $_->[0] } @{ Data::OptList::mkopt($options{superclasses} || []) } | ||||
| 121 | ); | ||||
| 122 | |||||
| 123 | my $roles = Data::OptList::mkopt(($options{roles} || []), { | ||||
| 124 | moniker => 'role', | ||||
| 125 | val_test => sub { ref($_[0]) eq 'HASH' }, | ||||
| 126 | }); | ||||
| 127 | |||||
| 128 | my @role_keys; | ||||
| 129 | for my $role_spec (@$roles) { | ||||
| 130 | my ($role, $params) = @$role_spec; | ||||
| 131 | $params = { %$params } if $params; | ||||
| 132 | |||||
| 133 | my $key = blessed($role) ? $role->name : $role; | ||||
| 134 | |||||
| 135 | if ($params && %$params) { | ||||
| 136 | my $alias = delete $params->{'-alias'} | ||||
| 137 | || delete $params->{'alias'} | ||||
| 138 | || {}; | ||||
| 139 | my $excludes = delete $params->{'-excludes'} | ||||
| 140 | || delete $params->{'excludes'} | ||||
| 141 | || []; | ||||
| 142 | $excludes = [$excludes] unless ref($excludes) eq 'ARRAY'; | ||||
| 143 | |||||
| 144 | if (%$params) { | ||||
| 145 | warn "Roles with parameters cannot be cached. Consider " | ||||
| 146 | . "applying the parameters before calling " | ||||
| 147 | . "create_anon_class, or using 'weaken => 0' instead"; | ||||
| 148 | return; | ||||
| 149 | } | ||||
| 150 | |||||
| 151 | my $alias_key = join('%', | ||||
| 152 | map { $_ => $alias->{$_} } sort keys %$alias | ||||
| 153 | ); | ||||
| 154 | my $excludes_key = join('%', | ||||
| 155 | sort @$excludes | ||||
| 156 | ); | ||||
| 157 | $key .= '<' . join('+', 'a', $alias_key, 'e', $excludes_key) . '>'; | ||||
| 158 | } | ||||
| 159 | |||||
| 160 | push @role_keys, $key; | ||||
| 161 | } | ||||
| 162 | |||||
| 163 | my $role_key = join('|', sort @role_keys); | ||||
| 164 | |||||
| 165 | # Makes something like Super::Class|Super::Class::2=Role|Role::1 | ||||
| 166 | return join('=', $superclass_key, $role_key); | ||||
| 167 | } | ||||
| 168 | |||||
| 169 | sub reinitialize { | ||||
| 170 | my $self = shift; | ||||
| 171 | my $pkg = shift; | ||||
| 172 | |||||
| 173 | my $meta = blessed $pkg ? $pkg : Class::MOP::class_of($pkg); | ||||
| 174 | |||||
| 175 | my %existing_classes; | ||||
| 176 | if ($meta) { | ||||
| 177 | %existing_classes = map { $_ => $meta->$_() } qw( | ||||
| 178 | attribute_metaclass | ||||
| 179 | method_metaclass | ||||
| 180 | wrapped_method_metaclass | ||||
| 181 | instance_metaclass | ||||
| 182 | constructor_class | ||||
| 183 | destructor_class | ||||
| 184 | error_class | ||||
| 185 | ); | ||||
| 186 | } | ||||
| 187 | |||||
| 188 | return $self->SUPER::reinitialize( | ||||
| 189 | $pkg, | ||||
| 190 | %existing_classes, | ||||
| 191 | @_, | ||||
| 192 | ); | ||||
| 193 | } | ||||
| 194 | |||||
| 195 | # spent 84µs (60+24) within Moose::Meta::Class::add_role which was called 4 times, avg 21µs/call:
# 4 times (60µs+24µs) by Moose::Meta::Role::Application::ToClass::apply at line 38 of Moose/Meta/Role/Application/ToClass.pm, avg 21µs/call | ||||
| 196 | 4 | 3µs | my ($self, $role) = @_; | ||
| 197 | 4 | 40µs | 8 | 11µs | (blessed($role) && $role->isa('Moose::Meta::Role')) # spent 6µs making 4 calls to Scalar::Util::blessed, avg 1µs/call
# spent 5µs making 4 calls to UNIVERSAL::isa, avg 1µs/call |
| 198 | || $self->throw_error("Roles must be instances of Moose::Meta::Role", data => $role); | ||||
| 199 | 4 | 28µs | 4 | 13µs | push @{$self->roles} => $role; # spent 13µs making 4 calls to Moose::Meta::Class::roles, avg 3µs/call |
| 200 | } | ||||
| 201 | |||||
| 202 | sub role_applications { | ||||
| 203 | my ($self) = @_; | ||||
| 204 | |||||
| 205 | return @{$self->_get_role_applications}; | ||||
| 206 | } | ||||
| 207 | |||||
| 208 | # spent 85µs (59+25) within Moose::Meta::Class::add_role_application which was called 4 times, avg 21µs/call:
# 4 times (59µs+25µs) by Moose::Meta::Role::Application::ToClass::apply at line 39 of Moose/Meta/Role/Application/ToClass.pm, avg 21µs/call | ||||
| 209 | 4 | 4µs | my ($self, $application) = @_; | ||
| 210 | 4 | 39µs | 8 | 10µs | (blessed($application) && $application->isa('Moose::Meta::Role::Application::ToClass')) # spent 6µs making 4 calls to UNIVERSAL::isa, avg 1µs/call
# spent 4µs making 4 calls to Scalar::Util::blessed, avg 1µs/call |
| 211 | || $self->throw_error("Role applications must be instances of Moose::Meta::Role::Application::ToClass", data => $application); | ||||
| 212 | 4 | 30µs | 4 | 15µs | push @{$self->_get_role_applications} => $application; # spent 15µs making 4 calls to Moose::Meta::Class::_get_role_applications, avg 4µs/call |
| 213 | } | ||||
| 214 | |||||
| 215 | sub calculate_all_roles { | ||||
| 216 | my $self = shift; | ||||
| 217 | my %seen; | ||||
| 218 | grep { !$seen{$_->name}++ } map { $_->calculate_all_roles } @{ $self->roles }; | ||||
| 219 | } | ||||
| 220 | |||||
| 221 | sub calculate_all_roles_with_inheritance { | ||||
| 222 | my $self = shift; | ||||
| 223 | my %seen; | ||||
| 224 | grep { !$seen{$_->name}++ } | ||||
| 225 | map { Class::MOP::class_of($_)->can('calculate_all_roles') | ||||
| 226 | ? Class::MOP::class_of($_)->calculate_all_roles | ||||
| 227 | : () } | ||||
| 228 | $self->linearized_isa; | ||||
| 229 | } | ||||
| 230 | |||||
| 231 | # spent 1.15ms (130µs+1.02) within Moose::Meta::Class::does_role which was called 3 times, avg 382µs/call:
# 3 times (130µs+1.02ms) by Moose::Object::does at line 125 of Moose/Object.pm, avg 382µs/call | ||||
| 232 | 3 | 5µs | my ($self, $role_name) = @_; | ||
| 233 | |||||
| 234 | 3 | 1µs | (defined $role_name) | ||
| 235 | || $self->throw_error("You must supply a role name to look for"); | ||||
| 236 | |||||
| 237 | 3 | 17µs | 3 | 884µs | foreach my $class ($self->class_precedence_list) { # spent 884µs making 3 calls to Class::MOP::Class::class_precedence_list, avg 295µs/call |
| 238 | 3 | 14µs | 3 | 41µs | my $meta = Class::MOP::class_of($class); # spent 41µs making 3 calls to Class::MOP::class_of, avg 14µs/call |
| 239 | # when a Moose metaclass is itself extended with a role, | ||||
| 240 | # this check needs to be done since some items in the | ||||
| 241 | # class_precedence_list might in fact be Class::MOP | ||||
| 242 | # based still. | ||||
| 243 | 3 | 29µs | 3 | 9µs | next unless $meta && $meta->can('roles'); # spent 9µs making 3 calls to UNIVERSAL::can, avg 3µs/call |
| 244 | 3 | 13µs | 3 | 15µs | foreach my $role (@{$meta->roles}) { # spent 15µs making 3 calls to Moose::Meta::Class::roles, avg 5µs/call |
| 245 | 3 | 36µs | 3 | 67µs | return 1 if $role->does_role($role_name); # spent 67µs making 3 calls to Moose::Meta::Role::does_role, avg 22µs/call |
| 246 | } | ||||
| 247 | } | ||||
| 248 | return 0; | ||||
| 249 | } | ||||
| 250 | |||||
| 251 | # spent 1.28ms (223µs+1.06) within Moose::Meta::Class::excludes_role which was called 4 times, avg 320µs/call:
# 4 times (223µs+1.06ms) by Moose::Meta::Role::Application::ToClass::check_role_exclusions at line 44 of Moose/Meta/Role/Application/ToClass.pm, avg 320µs/call | ||||
| 252 | 4 | 8µs | my ($self, $role_name) = @_; | ||
| 253 | |||||
| 254 | 4 | 2µs | (defined $role_name) | ||
| 255 | || $self->throw_error("You must supply a role name to look for"); | ||||
| 256 | |||||
| 257 | 4 | 39µs | 4 | 936µs | foreach my $class ($self->class_precedence_list) { # spent 936µs making 4 calls to Class::MOP::Class::class_precedence_list, avg 234µs/call |
| 258 | 11 | 17µs | 11 | 54µs | my $meta = Class::MOP::class_of($class); # spent 54µs making 11 calls to Class::MOP::class_of, avg 5µs/call |
| 259 | # when a Moose metaclass is itself extended with a role, | ||||
| 260 | # this check needs to be done since some items in the | ||||
| 261 | # class_precedence_list might in fact be Class::MOP | ||||
| 262 | # based still. | ||||
| 263 | 11 | 52µs | 11 | 16µs | next unless $meta && $meta->can('roles'); # spent 16µs making 11 calls to UNIVERSAL::can, avg 1µs/call |
| 264 | 11 | 35µs | 11 | 28µs | foreach my $role (@{$meta->roles}) { # spent 28µs making 11 calls to Moose::Meta::Class::roles, avg 3µs/call |
| 265 | 2 | 7µs | 2 | 23µs | return 1 if $role->excludes_role($role_name); # spent 23µs making 2 calls to Moose::Meta::Role::excludes_role, avg 11µs/call |
| 266 | } | ||||
| 267 | } | ||||
| 268 | 4 | 16µs | return 0; | ||
| 269 | } | ||||
| 270 | |||||
| 271 | # spent 4.07ms (66µs+4.00) within Moose::Meta::Class::new_object which was called 3 times, avg 1.36ms/call:
# 3 times (66µs+4.00ms) by Moose::Object::new at line 28 of Moose/Object.pm, avg 1.36ms/call | ||||
| 272 | 3 | 2µs | my $self = shift; | ||
| 273 | 3 | 1µs | my $params = @_ == 1 ? $_[0] : {@_}; | ||
| 274 | 3 | 21µs | 3 | 3.83ms | my $object = $self->SUPER::new_object($params); # spent 3.99ms making 3 calls to Class::MOP::Class::new_object, avg 1.33ms/call, recursion: max depth 1, sum of overlapping time 165µs |
| 275 | |||||
| 276 | 3 | 6µs | 3 | 188µs | $self->_call_all_triggers($object, $params); # spent 188µs making 3 calls to Moose::Meta::Class::_call_all_triggers, avg 63µs/call |
| 277 | |||||
| 278 | 3 | 31µs | 6 | 35µs | $object->BUILDALL($params) if $object->can('BUILDALL'); # spent 27µs making 3 calls to Moose::Object::BUILDALL, avg 9µs/call
# spent 8µs making 3 calls to UNIVERSAL::can, avg 3µs/call |
| 279 | |||||
| 280 | 3 | 7µs | return $object; | ||
| 281 | } | ||||
| 282 | |||||
| 283 | # spent 188µs (46+141) within Moose::Meta::Class::_call_all_triggers which was called 3 times, avg 63µs/call:
# 3 times (46µs+141µs) by Moose::Meta::Class::new_object at line 276, avg 63µs/call | ||||
| 284 | 3 | 2µs | my ($self, $object, $params) = @_; | ||
| 285 | |||||
| 286 | 3 | 14µs | 3 | 126µs | foreach my $attr ( $self->get_all_attributes() ) { # spent 126µs making 3 calls to Class::MOP::Class::get_all_attributes, avg 42µs/call |
| 287 | |||||
| 288 | 8 | 30µs | 16 | 16µs | next unless $attr->can('has_trigger') && $attr->has_trigger; # spent 9µs making 8 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 1µs/call
# spent 7µs making 8 calls to UNIVERSAL::can, avg 812ns/call |
| 289 | |||||
| 290 | my $init_arg = $attr->init_arg; | ||||
| 291 | next unless defined $init_arg; | ||||
| 292 | next unless exists $params->{$init_arg}; | ||||
| 293 | |||||
| 294 | $attr->trigger->( | ||||
| 295 | $object, | ||||
| 296 | ( | ||||
| 297 | $attr->should_coerce | ||||
| 298 | ? $attr->get_read_method_ref->($object) | ||||
| 299 | : $params->{$init_arg} | ||||
| 300 | ), | ||||
| 301 | ); | ||||
| 302 | } | ||||
| 303 | } | ||||
| 304 | |||||
| 305 | sub _generate_fallback_constructor { | ||||
| 306 | my $self = shift; | ||||
| 307 | my ($class) = @_; | ||||
| 308 | return $class . '->Moose::Object::new(@_)' | ||||
| 309 | } | ||||
| 310 | |||||
| 311 | sub _inline_params { | ||||
| 312 | my $self = shift; | ||||
| 313 | my ($params, $class) = @_; | ||||
| 314 | return ( | ||||
| 315 | 'my ' . $params . ' = ', | ||||
| 316 | $self->_inline_BUILDARGS($class, '@_'), | ||||
| 317 | ';', | ||||
| 318 | ); | ||||
| 319 | } | ||||
| 320 | |||||
| 321 | sub _inline_BUILDARGS { | ||||
| 322 | my $self = shift; | ||||
| 323 | my ($class, $args) = @_; | ||||
| 324 | |||||
| 325 | my $buildargs = $self->find_method_by_name("BUILDARGS"); | ||||
| 326 | |||||
| 327 | if ($args eq '@_' | ||||
| 328 | && (!$buildargs or $buildargs->body == \&Moose::Object::BUILDARGS)) { | ||||
| 329 | return ( | ||||
| 330 | 'do {', | ||||
| 331 | 'my $params;', | ||||
| 332 | 'if (scalar @_ == 1) {', | ||||
| 333 | 'if (!defined($_[0]) || ref($_[0]) ne \'HASH\') {', | ||||
| 334 | $self->_inline_throw_error( | ||||
| 335 | '"Single parameters to new() must be a HASH ref"', | ||||
| 336 | 'data => $_[0]', | ||||
| 337 | ) . ';', | ||||
| 338 | '}', | ||||
| 339 | '$params = { %{ $_[0] } };', | ||||
| 340 | '}', | ||||
| 341 | 'elsif (@_ % 2) {', | ||||
| 342 | 'Carp::carp(', | ||||
| 343 | '"The new() method for ' . $class . ' expects a ' | ||||
| 344 | . 'hash reference or a key/value list. You passed an ' | ||||
| 345 | . 'odd number of arguments"', | ||||
| 346 | ');', | ||||
| 347 | '$params = {@_, undef};', | ||||
| 348 | '}', | ||||
| 349 | 'else {', | ||||
| 350 | '$params = {@_};', | ||||
| 351 | '}', | ||||
| 352 | '$params;', | ||||
| 353 | '}', | ||||
| 354 | ); | ||||
| 355 | } | ||||
| 356 | else { | ||||
| 357 | return $class . '->BUILDARGS(' . $args . ')'; | ||||
| 358 | } | ||||
| 359 | } | ||||
| 360 | |||||
| 361 | sub _inline_slot_initializer { | ||||
| 362 | my $self = shift; | ||||
| 363 | my ($attr, $idx) = @_; | ||||
| 364 | |||||
| 365 | return ( | ||||
| 366 | '## ' . $attr->name, | ||||
| 367 | $self->_inline_check_required_attr($attr), | ||||
| 368 | $self->SUPER::_inline_slot_initializer(@_), | ||||
| 369 | ); | ||||
| 370 | } | ||||
| 371 | |||||
| 372 | sub _inline_check_required_attr { | ||||
| 373 | my $self = shift; | ||||
| 374 | my ($attr) = @_; | ||||
| 375 | |||||
| 376 | return unless defined $attr->init_arg; | ||||
| 377 | return unless $attr->can('is_required') && $attr->is_required; | ||||
| 378 | return if $attr->has_default || $attr->has_builder; | ||||
| 379 | |||||
| 380 | return ( | ||||
| 381 | 'if (!exists $params->{\'' . $attr->init_arg . '\'}) {', | ||||
| 382 | $self->_inline_throw_error( | ||||
| 383 | '"Attribute (' . quotemeta($attr->name) . ') is required"' | ||||
| 384 | ) . ';', | ||||
| 385 | '}', | ||||
| 386 | ); | ||||
| 387 | } | ||||
| 388 | |||||
| 389 | # XXX: these two are duplicated from cmop, because we have to pass the tc stuff | ||||
| 390 | # through to _inline_set_value - this should probably be fixed, but i'm not | ||||
| 391 | # quite sure how. -doy | ||||
| 392 | sub _inline_init_attr_from_constructor { | ||||
| 393 | my $self = shift; | ||||
| 394 | my ($attr, $idx) = @_; | ||||
| 395 | |||||
| 396 | my @initial_value = $attr->_inline_set_value( | ||||
| 397 | '$instance', | ||||
| 398 | '$params->{\'' . $attr->init_arg . '\'}', | ||||
| 399 | '$type_constraint_bodies[' . $idx . ']', | ||||
| 400 | '$type_coercions[' . $idx . ']', | ||||
| 401 | '$type_constraint_messages[' . $idx . ']', | ||||
| 402 | 'for constructor', | ||||
| 403 | ); | ||||
| 404 | |||||
| 405 | push @initial_value, ( | ||||
| 406 | '$attrs->[' . $idx . ']->set_initial_value(', | ||||
| 407 | '$instance,', | ||||
| 408 | $attr->_inline_instance_get('$instance'), | ||||
| 409 | ');', | ||||
| 410 | ) if $attr->has_initializer; | ||||
| 411 | |||||
| 412 | return @initial_value; | ||||
| 413 | } | ||||
| 414 | |||||
| 415 | sub _inline_init_attr_from_default { | ||||
| 416 | my $self = shift; | ||||
| 417 | my ($attr, $idx) = @_; | ||||
| 418 | |||||
| 419 | return if $attr->can('is_lazy') && $attr->is_lazy; | ||||
| 420 | my $default = $self->_inline_default_value($attr, $idx); | ||||
| 421 | return unless $default; | ||||
| 422 | |||||
| 423 | my @initial_value = ( | ||||
| 424 | 'my $default = ' . $default . ';', | ||||
| 425 | $attr->_inline_set_value( | ||||
| 426 | '$instance', | ||||
| 427 | '$default', | ||||
| 428 | '$type_constraint_bodies[' . $idx . ']', | ||||
| 429 | '$type_coercions[' . $idx . ']', | ||||
| 430 | '$type_constraint_messages[' . $idx . ']', | ||||
| 431 | 'for constructor', | ||||
| 432 | ), | ||||
| 433 | ); | ||||
| 434 | |||||
| 435 | push @initial_value, ( | ||||
| 436 | '$attrs->[' . $idx . ']->set_initial_value(', | ||||
| 437 | '$instance,', | ||||
| 438 | $attr->_inline_instance_get('$instance'), | ||||
| 439 | ');', | ||||
| 440 | ) if $attr->has_initializer; | ||||
| 441 | |||||
| 442 | return @initial_value; | ||||
| 443 | } | ||||
| 444 | |||||
| 445 | sub _inline_extra_init { | ||||
| 446 | my $self = shift; | ||||
| 447 | return ( | ||||
| 448 | $self->_inline_triggers, | ||||
| 449 | $self->_inline_BUILDALL, | ||||
| 450 | ); | ||||
| 451 | } | ||||
| 452 | |||||
| 453 | sub _inline_triggers { | ||||
| 454 | my $self = shift; | ||||
| 455 | my @trigger_calls; | ||||
| 456 | |||||
| 457 | my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes; | ||||
| 458 | for my $i (0 .. $#attrs) { | ||||
| 459 | my $attr = $attrs[$i]; | ||||
| 460 | |||||
| 461 | next unless $attr->can('has_trigger') && $attr->has_trigger; | ||||
| 462 | |||||
| 463 | my $init_arg = $attr->init_arg; | ||||
| 464 | next unless defined $init_arg; | ||||
| 465 | |||||
| 466 | push @trigger_calls, | ||||
| 467 | 'if (exists $params->{\'' . $init_arg . '\'}) {', | ||||
| 468 | '$triggers->[' . $i . ']->(', | ||||
| 469 | '$instance,', | ||||
| 470 | $attr->_inline_instance_get('$instance') . ',', | ||||
| 471 | ');', | ||||
| 472 | '}'; | ||||
| 473 | } | ||||
| 474 | |||||
| 475 | return @trigger_calls; | ||||
| 476 | } | ||||
| 477 | |||||
| 478 | sub _inline_BUILDALL { | ||||
| 479 | my $self = shift; | ||||
| 480 | |||||
| 481 | my @methods = reverse $self->find_all_methods_by_name('BUILD'); | ||||
| 482 | my @BUILD_calls; | ||||
| 483 | |||||
| 484 | foreach my $method (@methods) { | ||||
| 485 | push @BUILD_calls, | ||||
| 486 | '$instance->' . $method->{class} . '::BUILD($params);'; | ||||
| 487 | } | ||||
| 488 | |||||
| 489 | return @BUILD_calls; | ||||
| 490 | } | ||||
| 491 | |||||
| 492 | sub _eval_environment { | ||||
| 493 | my $self = shift; | ||||
| 494 | |||||
| 495 | my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes; | ||||
| 496 | |||||
| 497 | my $triggers = [ | ||||
| 498 | map { $_->can('has_trigger') && $_->has_trigger ? $_->trigger : undef } | ||||
| 499 | @attrs | ||||
| 500 | ]; | ||||
| 501 | |||||
| 502 | # We need to check if the attribute ->can('type_constraint') | ||||
| 503 | # since we may be trying to immutabilize a Moose meta class, | ||||
| 504 | # which in turn has attributes which are Class::MOP::Attribute | ||||
| 505 | # objects, rather than Moose::Meta::Attribute. And | ||||
| 506 | # Class::MOP::Attribute attributes have no type constraints. | ||||
| 507 | # However we need to make sure we leave an undef value there | ||||
| 508 | # because the inlined code is using the index of the attributes | ||||
| 509 | # to determine where to find the type constraint | ||||
| 510 | |||||
| 511 | my @type_constraints = map { | ||||
| 512 | $_->can('type_constraint') ? $_->type_constraint : undef | ||||
| 513 | } @attrs; | ||||
| 514 | |||||
| 515 | my @type_constraint_bodies = map { | ||||
| 516 | defined $_ ? $_->_compiled_type_constraint : undef; | ||||
| 517 | } @type_constraints; | ||||
| 518 | |||||
| 519 | my @type_coercions = map { | ||||
| 520 | defined $_ && $_->has_coercion | ||||
| 521 | ? $_->coercion->_compiled_type_coercion | ||||
| 522 | : undef | ||||
| 523 | } @type_constraints; | ||||
| 524 | |||||
| 525 | my @type_constraint_messages = map { | ||||
| 526 | defined $_ | ||||
| 527 | ? ($_->has_message ? $_->message : $_->_default_message) | ||||
| 528 | : undef | ||||
| 529 | } @type_constraints; | ||||
| 530 | |||||
| 531 | return { | ||||
| 532 | %{ $self->SUPER::_eval_environment }, | ||||
| 533 | ((any { defined && $_->has_initializer } @attrs) | ||||
| 534 | ? ('$attrs' => \[@attrs]) | ||||
| 535 | : ()), | ||||
| 536 | '$triggers' => \$triggers, | ||||
| 537 | '@type_coercions' => \@type_coercions, | ||||
| 538 | '@type_constraint_bodies' => \@type_constraint_bodies, | ||||
| 539 | '@type_constraint_messages' => \@type_constraint_messages, | ||||
| 540 | ( map { defined($_) ? %{ $_->inline_environment } : () } | ||||
| 541 | @type_constraints ), | ||||
| 542 | # pretty sure this is only going to be closed over if you use a custom | ||||
| 543 | # error class at this point, but we should still get rid of this | ||||
| 544 | # at some point | ||||
| 545 | '$meta' => \$self, | ||||
| 546 | }; | ||||
| 547 | } | ||||
| 548 | |||||
| 549 | # spent 16.2ms (948µs+15.3) within Moose::Meta::Class::superclasses which was called 63 times, avg 257µs/call:
# 19 times (239µs+631µs) by Class::MOP::Class::_check_metaclass_compatibility at line 203 of Class/MOP/Class.pm, avg 46µs/call
# 17 times (313µs+820µs) by Class::MOP::Class::class_precedence_list at line 1030 of Class/MOP/Class.pm, avg 67µs/call
# 14 times (200µs+5.15ms) by Moose::init_meta at line 215 of Moose.pm, avg 382µs/call
# 10 times (94µs+-94µs) by Class::MOP::Class::_superclasses_updated at line 971 of Class/MOP/Class.pm, avg 0s/call
# 2 times (44µs+6.42ms) by Moose::extends at line 63 of Moose.pm, avg 3.23ms/call
# once (58µs+2.33ms) by Class::MOP::Class::create at line 451 of Class/MOP/Class.pm | ||||
| 550 | 63 | 26µs | my $self = shift; | ||
| 551 | 63 | 146µs | 63 | 826µs | my $supers = Data::OptList::mkopt(\@_); # spent 826µs making 63 calls to Data::OptList::mkopt, avg 13µs/call |
| 552 | 63 | 65µs | foreach my $super (@{ $supers }) { | ||
| 553 | 10 | 11µs | my ($name, $opts) = @{ $super }; | ||
| 554 | 10 | 32µs | 10 | 6.15ms | load_class($name, $opts); # spent 6.24ms making 10 calls to Class::Load::load_class, avg 624µs/call, recursion: max depth 1, sum of overlapping time 87µs |
| 555 | 10 | 24µs | 10 | 108µs | my $meta = Class::MOP::class_of($name); # spent 108µs making 10 calls to Class::MOP::class_of, avg 11µs/call |
| 556 | 10 | 76µs | 10 | 30µs | $self->throw_error("You cannot inherit from a Moose Role ($name)") # spent 30µs making 10 calls to UNIVERSAL::isa, avg 3µs/call |
| 557 | if $meta && $meta->isa('Moose::Meta::Role') | ||||
| 558 | } | ||||
| 559 | 63 | 550µs | 63 | 10.1ms | return $self->SUPER::superclasses(map { $_->[0] } @{ $supers }); # spent 10.4ms making 63 calls to Class::MOP::Class::superclasses, avg 166µs/call, recursion: max depth 1, sum of overlapping time 317µs |
| 560 | } | ||||
| 561 | |||||
| 562 | ### --------------------------------------------- | ||||
| 563 | |||||
| 564 | # spent 17.8ms (240µs+17.5) within Moose::Meta::Class::add_attribute which was called 8 times, avg 2.22ms/call:
# 6 times (149µs+14.0ms) by Moose::has at line 79 of Moose.pm, avg 2.35ms/call
# 2 times (92µs+3.54ms) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 152 of Moose/Meta/Role/Application/ToClass.pm, avg 1.81ms/call | ||||
| 565 | 8 | 4µs | my $self = shift; | ||
| 566 | 8 | 76µs | 16 | 2.50ms | my $attr = # spent 2.49ms making 6 calls to Moose::Meta::Class::_process_attribute, avg 415µs/call
# spent 8µs making 8 calls to Scalar::Util::blessed, avg 950ns/call
# spent 5µs making 2 calls to UNIVERSAL::isa, avg 2µs/call |
| 567 | (blessed $_[0] && $_[0]->isa('Class::MOP::Attribute') | ||||
| 568 | ? $_[0] | ||||
| 569 | : $self->_process_attribute(@_)); | ||||
| 570 | 8 | 62µs | 8 | 14.9ms | $self->SUPER::add_attribute($attr); # spent 14.9ms making 8 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 1.86ms/call |
| 571 | # it may be a Class::MOP::Attribute, theoretically, which doesn't have | ||||
| 572 | # 'bare' and doesn't implement this method | ||||
| 573 | 8 | 75µs | 16 | 126µs | if ($attr->can('_check_associated_methods')) { # spent 111µs making 8 calls to Moose::Meta::Attribute::_check_associated_methods, avg 14µs/call
# spent 15µs making 8 calls to UNIVERSAL::can, avg 2µs/call |
| 574 | $attr->_check_associated_methods; | ||||
| 575 | } | ||||
| 576 | 8 | 33µs | return $attr; | ||
| 577 | } | ||||
| 578 | |||||
| 579 | sub add_override_method_modifier { | ||||
| 580 | my ($self, $name, $method, $_super_package) = @_; | ||||
| 581 | |||||
| 582 | (!$self->has_method($name)) | ||||
| 583 | || $self->throw_error("Cannot add an override method if a local method is already present"); | ||||
| 584 | |||||
| 585 | $self->add_method($name => Moose::Meta::Method::Overridden->new( | ||||
| 586 | method => $method, | ||||
| 587 | class => $self, | ||||
| 588 | package => $_super_package, # need this for roles | ||||
| 589 | name => $name, | ||||
| 590 | )); | ||||
| 591 | } | ||||
| 592 | |||||
| 593 | sub add_augment_method_modifier { | ||||
| 594 | my ($self, $name, $method) = @_; | ||||
| 595 | (!$self->has_method($name)) | ||||
| 596 | || $self->throw_error("Cannot add an augment method if a local method is already present"); | ||||
| 597 | |||||
| 598 | $self->add_method($name => Moose::Meta::Method::Augmented->new( | ||||
| 599 | method => $method, | ||||
| 600 | class => $self, | ||||
| 601 | name => $name, | ||||
| 602 | )); | ||||
| 603 | } | ||||
| 604 | |||||
| 605 | ## Private Utility methods ... | ||||
| 606 | |||||
| 607 | sub _find_next_method_by_name_which_is_not_overridden { | ||||
| 608 | my ($self, $name) = @_; | ||||
| 609 | foreach my $method ($self->find_all_methods_by_name($name)) { | ||||
| 610 | return $method->{code} | ||||
| 611 | if blessed($method->{code}) && !$method->{code}->isa('Moose::Meta::Method::Overridden'); | ||||
| 612 | } | ||||
| 613 | return undef; | ||||
| 614 | } | ||||
| 615 | |||||
| 616 | ## Metaclass compatibility | ||||
| 617 | |||||
| 618 | # spent 843µs (585+258) within Moose::Meta::Class::_base_metaclasses which was called 20 times, avg 42µs/call:
# 10 times (330µs+152µs) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 333 of Class/MOP/Class.pm, avg 48µs/call
# 10 times (255µs+106µs) by Class::MOP::Class::_check_metaclass_compatibility at line 208 of Class/MOP/Class.pm, avg 36µs/call | ||||
| 619 | 20 | 9µs | my $self = shift; | ||
| 620 | 20 | 186µs | 20 | 73µs | my %metaclasses = $self->SUPER::_base_metaclasses; # spent 73µs making 20 calls to Class::MOP::Class::_base_metaclasses, avg 4µs/call |
| 621 | 20 | 33µs | for my $class (keys %metaclasses) { | ||
| 622 | 120 | 432µs | 120 | 185µs | $metaclasses{$class} =~ s/^Class::MOP/Moose::Meta/; # spent 185µs making 120 calls to Moose::Meta::Class::CORE:subst, avg 2µs/call |
| 623 | } | ||||
| 624 | return ( | ||||
| 625 | 20 | 110µs | %metaclasses, | ||
| 626 | error_class => 'Moose::Error::Default', | ||||
| 627 | ); | ||||
| 628 | } | ||||
| 629 | |||||
| 630 | sub _fix_class_metaclass_incompatibility { | ||||
| 631 | my $self = shift; | ||||
| 632 | my ($super_meta) = @_; | ||||
| 633 | |||||
| 634 | $self->SUPER::_fix_class_metaclass_incompatibility(@_); | ||||
| 635 | |||||
| 636 | if ($self->_class_metaclass_can_be_made_compatible($super_meta)) { | ||||
| 637 | ($self->is_pristine) | ||||
| 638 | || confess "Can't fix metaclass incompatibility for " | ||||
| 639 | . $self->name | ||||
| 640 | . " because it is not pristine."; | ||||
| 641 | my $super_meta_name = $super_meta->_real_ref_name; | ||||
| 642 | my $class_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass(blessed($self), $super_meta_name); | ||||
| 643 | my $new_self = $class_meta_subclass_meta_name->reinitialize( | ||||
| 644 | $self->name, | ||||
| 645 | ); | ||||
| 646 | |||||
| 647 | $self->_replace_self( $new_self, $class_meta_subclass_meta_name ); | ||||
| 648 | } | ||||
| 649 | } | ||||
| 650 | |||||
| 651 | sub _fix_single_metaclass_incompatibility { | ||||
| 652 | my $self = shift; | ||||
| 653 | my ($metaclass_type, $super_meta) = @_; | ||||
| 654 | |||||
| 655 | $self->SUPER::_fix_single_metaclass_incompatibility(@_); | ||||
| 656 | |||||
| 657 | if ($self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type)) { | ||||
| 658 | ($self->is_pristine) | ||||
| 659 | || confess "Can't fix metaclass incompatibility for " | ||||
| 660 | . $self->name | ||||
| 661 | . " because it is not pristine."; | ||||
| 662 | my $super_meta_name = $super_meta->_real_ref_name; | ||||
| 663 | my $class_specific_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass($self->$metaclass_type, $super_meta->$metaclass_type); | ||||
| 664 | my $new_self = $super_meta->reinitialize( | ||||
| 665 | $self->name, | ||||
| 666 | $metaclass_type => $class_specific_meta_subclass_meta_name, | ||||
| 667 | ); | ||||
| 668 | |||||
| 669 | $self->_replace_self( $new_self, $super_meta_name ); | ||||
| 670 | } | ||||
| 671 | } | ||||
| 672 | |||||
| 673 | sub _replace_self { | ||||
| 674 | my $self = shift; | ||||
| 675 | my ( $new_self, $new_class) = @_; | ||||
| 676 | |||||
| 677 | %$self = %$new_self; | ||||
| 678 | bless $self, $new_class; | ||||
| 679 | |||||
| 680 | # We need to replace the cached metaclass instance or else when it goes | ||||
| 681 | # out of scope Class::MOP::Class destroy's the namespace for the | ||||
| 682 | # metaclass's class, causing much havoc. | ||||
| 683 | my $weaken = Class::MOP::metaclass_is_weak( $self->name ); | ||||
| 684 | Class::MOP::store_metaclass_by_name( $self->name, $self ); | ||||
| 685 | Class::MOP::weaken_metaclass( $self->name ) if $weaken; | ||||
| 686 | } | ||||
| 687 | |||||
| 688 | # spent 2.49ms (68µs+2.42) within Moose::Meta::Class::_process_attribute which was called 6 times, avg 415µs/call:
# 6 times (68µs+2.42ms) by Moose::Meta::Class::add_attribute at line 566, avg 415µs/call | ||||
| 689 | 6 | 13µs | my ( $self, $name, @args ) = @_; | ||
| 690 | |||||
| 691 | 6 | 4µs | @args = %{$args[0]} if scalar @args == 1 && ref($args[0]) eq 'HASH'; | ||
| 692 | |||||
| 693 | 6 | 24µs | 6 | 6µs | if (($name || '') =~ /^\+(.*)/) { # spent 6µs making 6 calls to Moose::Meta::Class::CORE:match, avg 1µs/call |
| 694 | return $self->_process_inherited_attribute($1, @args); | ||||
| 695 | } | ||||
| 696 | else { | ||||
| 697 | 6 | 29µs | 6 | 2.42ms | return $self->_process_new_attribute($name, @args); # spent 2.42ms making 6 calls to Moose::Meta::Class::_process_new_attribute, avg 403µs/call |
| 698 | } | ||||
| 699 | } | ||||
| 700 | |||||
| 701 | # spent 2.42ms (66µs+2.35) within Moose::Meta::Class::_process_new_attribute which was called 6 times, avg 403µs/call:
# 6 times (66µs+2.35ms) by Moose::Meta::Class::_process_attribute at line 697, avg 403µs/call | ||||
| 702 | 6 | 10µs | my ( $self, $name, @args ) = @_; | ||
| 703 | |||||
| 704 | 6 | 66µs | 12 | 2.35ms | $self->attribute_metaclass->interpolate_class_and_new($name, @args); # spent 2.34ms making 6 calls to Moose::Meta::Attribute::interpolate_class_and_new, avg 391µs/call
# spent 7µs making 6 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 1µs/call |
| 705 | } | ||||
| 706 | |||||
| 707 | sub _process_inherited_attribute { | ||||
| 708 | my ($self, $attr_name, %options) = @_; | ||||
| 709 | my $inherited_attr = $self->find_attribute_by_name($attr_name); | ||||
| 710 | (defined $inherited_attr) | ||||
| 711 | || $self->throw_error("Could not find an attribute by the name of '$attr_name' to inherit from in ${\$self->name}", data => $attr_name); | ||||
| 712 | if ($inherited_attr->isa('Moose::Meta::Attribute')) { | ||||
| 713 | return $inherited_attr->clone_and_inherit_options(%options); | ||||
| 714 | } | ||||
| 715 | else { | ||||
| 716 | # NOTE: | ||||
| 717 | # kind of a kludge to handle Class::MOP::Attributes | ||||
| 718 | return $inherited_attr->Moose::Meta::Attribute::clone_and_inherit_options(%options); | ||||
| 719 | } | ||||
| 720 | } | ||||
| 721 | |||||
| 722 | # reinitialization support | ||||
| 723 | |||||
| 724 | sub _restore_metaobjects_from { | ||||
| 725 | my $self = shift; | ||||
| 726 | my ($old_meta) = @_; | ||||
| 727 | |||||
| 728 | $self->SUPER::_restore_metaobjects_from($old_meta); | ||||
| 729 | |||||
| 730 | for my $role ( @{ $old_meta->roles } ) { | ||||
| 731 | $self->add_role($role); | ||||
| 732 | } | ||||
| 733 | |||||
| 734 | for my $application ( @{ $old_meta->_get_role_applications } ) { | ||||
| 735 | $application->class($self); | ||||
| 736 | $self->add_role_application ($application); | ||||
| 737 | } | ||||
| 738 | } | ||||
| 739 | |||||
| 740 | ## Immutability | ||||
| 741 | |||||
| 742 | sub _immutable_options { | ||||
| 743 | my ( $self, @args ) = @_; | ||||
| 744 | |||||
| 745 | $self->SUPER::_immutable_options( | ||||
| 746 | inline_destructor => 1, | ||||
| 747 | |||||
| 748 | # Moose always does this when an attribute is created | ||||
| 749 | inline_accessors => 0, | ||||
| 750 | |||||
| 751 | @args, | ||||
| 752 | ); | ||||
| 753 | } | ||||
| 754 | |||||
| 755 | sub _fixup_attributes_after_rebless { | ||||
| 756 | my $self = shift; | ||||
| 757 | my ($instance, $rebless_from, %params) = @_; | ||||
| 758 | |||||
| 759 | $self->SUPER::_fixup_attributes_after_rebless( | ||||
| 760 | $instance, | ||||
| 761 | $rebless_from, | ||||
| 762 | %params | ||||
| 763 | ); | ||||
| 764 | |||||
| 765 | $self->_call_all_triggers( $instance, \%params ); | ||||
| 766 | } | ||||
| 767 | |||||
| 768 | ## ------------------------------------------------- | ||||
| 769 | |||||
| 770 | 1 | 500ns | our $error_level; | ||
| 771 | |||||
| 772 | sub throw_error { | ||||
| 773 | my ( $self, @args ) = @_; | ||||
| 774 | local $error_level = ($error_level || 0) + 1; | ||||
| 775 | $self->raise_error($self->create_error(@args)); | ||||
| 776 | } | ||||
| 777 | |||||
| 778 | # spent 1.18ms (80µs+1.10) within Moose::Meta::Class::_inline_throw_error which was called 9 times, avg 131µs/call:
# 9 times (80µs+1.10ms) by Moose::Meta::Attribute::_inline_throw_error at line 83 of Moose/Meta/Attribute.pm, avg 131µs/call | ||||
| 779 | 9 | 11µs | my ( $self, @args ) = @_; | ||
| 780 | 9 | 62µs | 18 | 1.10ms | $self->_inline_raise_error($self->_inline_create_error(@args)); # spent 1.07ms making 9 calls to Moose::Meta::Class::_inline_create_error, avg 119µs/call
# spent 30µs making 9 calls to Moose::Meta::Class::_inline_raise_error, avg 3µs/call |
| 781 | } | ||||
| 782 | |||||
| 783 | sub raise_error { | ||||
| 784 | my ( $self, @args ) = @_; | ||||
| 785 | die @args; | ||||
| 786 | } | ||||
| 787 | |||||
| 788 | # spent 30µs within Moose::Meta::Class::_inline_raise_error which was called 9 times, avg 3µs/call:
# 9 times (30µs+0s) by Moose::Meta::Class::_inline_throw_error at line 780, avg 3µs/call | ||||
| 789 | 9 | 7µs | my ( $self, $message ) = @_; | ||
| 790 | |||||
| 791 | 9 | 31µs | return 'die ' . $message; | ||
| 792 | } | ||||
| 793 | |||||
| 794 | sub create_error { | ||||
| 795 | my ( $self, @args ) = @_; | ||||
| 796 | |||||
| 797 | require Carp::Heavy; | ||||
| 798 | |||||
| 799 | local $error_level = ($error_level || 0 ) + 1; | ||||
| 800 | |||||
| 801 | if ( @args % 2 == 1 ) { | ||||
| 802 | unshift @args, "message"; | ||||
| 803 | } | ||||
| 804 | |||||
| 805 | my %args = ( metaclass => $self, last_error => $@, @args ); | ||||
| 806 | |||||
| 807 | $args{depth} += $error_level; | ||||
| 808 | |||||
| 809 | my $class = ref $self ? $self->error_class : "Moose::Error::Default"; | ||||
| 810 | |||||
| 811 | load_class($class); | ||||
| 812 | |||||
| 813 | $class->new( | ||||
| 814 | Carp::caller_info($args{depth}), | ||||
| 815 | %args | ||||
| 816 | ); | ||||
| 817 | } | ||||
| 818 | |||||
| 819 | # spent 1.07ms (250µs+822µs) within Moose::Meta::Class::_inline_create_error which was called 9 times, avg 119µs/call:
# 9 times (250µs+822µs) by Moose::Meta::Class::_inline_throw_error at line 780, avg 119µs/call | ||||
| 820 | 9 | 9µs | my ( $self, $msg, $args ) = @_; | ||
| 821 | # XXX ignore $args for now, nothing currently uses it anyway | ||||
| 822 | |||||
| 823 | 9 | 7µs | require Carp::Heavy; | ||
| 824 | |||||
| 825 | 9 | 29µs | my %args = ( | ||
| 826 | metaclass => $self, | ||||
| 827 | last_error => $@, | ||||
| 828 | message => $msg, | ||||
| 829 | ); | ||||
| 830 | |||||
| 831 | 9 | 24µs | 7 | 24µs | my $class = ref $self ? $self->error_class : "Moose::Error::Default"; # spent 24µs making 7 calls to Moose::Meta::Class::error_class, avg 3µs/call |
| 832 | |||||
| 833 | 9 | 25µs | 9 | 423µs | load_class($class); # spent 423µs making 9 calls to Class::Load::load_class, avg 47µs/call |
| 834 | |||||
| 835 | # don't check inheritance here - the intention is that the class needs | ||||
| 836 | # to provide a non-inherited inlining method, because falling back to | ||||
| 837 | # the default inlining method is most likely going to be wrong | ||||
| 838 | # yes, this is a huge hack, but so is the entire error system, so. | ||||
| 839 | return | ||||
| 840 | 9 | 82µs | 18 | 305µs | '$meta->create_error(' # spent 184µs making 9 calls to Class::MOP::Mixin::HasMethods::has_method, avg 20µs/call
# spent 121µs making 9 calls to Class::MOP::Object::meta, avg 13µs/call |
| 841 | . $msg | ||||
| 842 | . ( defined $args ? ', ' . $args : q{} ) . ');' | ||||
| 843 | unless $class->meta->has_method('_inline_new'); | ||||
| 844 | |||||
| 845 | 9 | 52µs | 9 | 70µs | $class->_inline_new( # spent 70µs making 9 calls to Moose::Error::Default::_inline_new, avg 8µs/call |
| 846 | # XXX ignore this for now too | ||||
| 847 | # Carp::caller_info($args{depth}), | ||||
| 848 | %args | ||||
| 849 | ); | ||||
| 850 | } | ||||
| 851 | |||||
| 852 | 1 | 26µs | 1; | ||
| 853 | |||||
| 854 | # ABSTRACT: The Moose metaclass | ||||
| 855 | |||||
| - - | |||||
| 858 | =pod | ||||
| 859 | |||||
| 860 | =head1 NAME | ||||
| 861 | |||||
| 862 | Moose::Meta::Class - The Moose metaclass | ||||
| 863 | |||||
| 864 | =head1 VERSION | ||||
| 865 | |||||
| 866 | version 2.0602 | ||||
| 867 | |||||
| 868 | =head1 DESCRIPTION | ||||
| 869 | |||||
| 870 | This class is a subclass of L<Class::MOP::Class> that provides | ||||
| 871 | additional Moose-specific functionality. | ||||
| 872 | |||||
| 873 | To really understand this class, you will need to start with the | ||||
| 874 | L<Class::MOP::Class> documentation. This class can be understood as a | ||||
| 875 | set of additional features on top of the basic feature provided by | ||||
| 876 | that parent class. | ||||
| 877 | |||||
| 878 | =head1 INHERITANCE | ||||
| 879 | |||||
| 880 | C<Moose::Meta::Class> is a subclass of L<Class::MOP::Class>. | ||||
| 881 | |||||
| 882 | =head1 METHODS | ||||
| 883 | |||||
| 884 | =over 4 | ||||
| 885 | |||||
| 886 | =item B<< Moose::Meta::Class->initialize($package_name, %options) >> | ||||
| 887 | |||||
| 888 | This overrides the parent's method in order to provide its own | ||||
| 889 | defaults for the C<attribute_metaclass>, C<instance_metaclass>, and | ||||
| 890 | C<method_metaclass> options. | ||||
| 891 | |||||
| 892 | These all default to the appropriate Moose class. | ||||
| 893 | |||||
| 894 | =item B<< Moose::Meta::Class->create($package_name, %options) >> | ||||
| 895 | |||||
| 896 | This overrides the parent's method in order to accept a C<roles> | ||||
| 897 | option. This should be an array reference containing roles | ||||
| 898 | that the class does, each optionally followed by a hashref of options | ||||
| 899 | (C<-excludes> and C<-alias>). | ||||
| 900 | |||||
| 901 | my $metaclass = Moose::Meta::Class->create( 'New::Class', roles => [...] ); | ||||
| 902 | |||||
| 903 | =item B<< Moose::Meta::Class->create_anon_class >> | ||||
| 904 | |||||
| 905 | This overrides the parent's method to accept a C<roles> option, just | ||||
| 906 | as C<create> does. | ||||
| 907 | |||||
| 908 | It also accepts a C<cache> option. If this is true, then the anonymous | ||||
| 909 | class will be cached based on its superclasses and roles. If an | ||||
| 910 | existing anonymous class in the cache has the same superclasses and | ||||
| 911 | roles, it will be reused. | ||||
| 912 | |||||
| 913 | my $metaclass = Moose::Meta::Class->create_anon_class( | ||||
| 914 | superclasses => ['Foo'], | ||||
| 915 | roles => [qw/Some Roles Go Here/], | ||||
| 916 | cache => 1, | ||||
| 917 | ); | ||||
| 918 | |||||
| 919 | Each entry in both the C<superclasses> and the C<roles> option can be | ||||
| 920 | followed by a hash reference with arguments. The C<superclasses> | ||||
| 921 | option can be supplied with a L<-version|Class::MOP/Class Loading | ||||
| 922 | Options> option that ensures the loaded superclass satisfies the | ||||
| 923 | required version. The C<role> option also takes the C<-version> as an | ||||
| 924 | argument, but the option hash reference can also contain any other | ||||
| 925 | role relevant values like exclusions or parameterized role arguments. | ||||
| 926 | |||||
| 927 | =item B<< $metaclass->new_object(%params) >> | ||||
| 928 | |||||
| 929 | This overrides the parent's method in order to add support for | ||||
| 930 | attribute triggers. | ||||
| 931 | |||||
| 932 | =item B<< $metaclass->superclasses(@superclasses) >> | ||||
| 933 | |||||
| 934 | This is the accessor allowing you to read or change the parents of | ||||
| 935 | the class. | ||||
| 936 | |||||
| 937 | Each superclass can be followed by a hash reference containing a | ||||
| 938 | L<-version|Class::MOP/Class Loading Options> value. If the version | ||||
| 939 | requirement is not satisfied an error will be thrown. | ||||
| 940 | |||||
| 941 | =item B<< $metaclass->add_override_method_modifier($name, $sub) >> | ||||
| 942 | |||||
| 943 | This adds an C<override> method modifier to the package. | ||||
| 944 | |||||
| 945 | =item B<< $metaclass->add_augment_method_modifier($name, $sub) >> | ||||
| 946 | |||||
| 947 | This adds an C<augment> method modifier to the package. | ||||
| 948 | |||||
| 949 | =item B<< $metaclass->calculate_all_roles >> | ||||
| 950 | |||||
| 951 | This will return a unique array of C<Moose::Meta::Role> instances | ||||
| 952 | which are attached to this class. | ||||
| 953 | |||||
| 954 | =item B<< $metaclass->calculate_all_roles_with_inheritance >> | ||||
| 955 | |||||
| 956 | This will return a unique array of C<Moose::Meta::Role> instances | ||||
| 957 | which are attached to this class, and each of this class's ancestors. | ||||
| 958 | |||||
| 959 | =item B<< $metaclass->add_role($role) >> | ||||
| 960 | |||||
| 961 | This takes a L<Moose::Meta::Role> object, and adds it to the class's | ||||
| 962 | list of roles. This I<does not> actually apply the role to the class. | ||||
| 963 | |||||
| 964 | =item B<< $metaclass->role_applications >> | ||||
| 965 | |||||
| 966 | Returns a list of L<Moose::Meta::Role::Application::ToClass> | ||||
| 967 | objects, which contain the arguments to role application. | ||||
| 968 | |||||
| 969 | =item B<< $metaclass->add_role_application($application) >> | ||||
| 970 | |||||
| 971 | This takes a L<Moose::Meta::Role::Application::ToClass> object, and | ||||
| 972 | adds it to the class's list of role applications. This I<does not> | ||||
| 973 | actually apply any role to the class; it is only for tracking role | ||||
| 974 | applications. | ||||
| 975 | |||||
| 976 | =item B<< $metaclass->does_role($role) >> | ||||
| 977 | |||||
| 978 | This returns a boolean indicating whether or not the class does the specified | ||||
| 979 | role. The role provided can be either a role name or a L<Moose::Meta::Role> | ||||
| 980 | object. This tests both the class and its parents. | ||||
| 981 | |||||
| 982 | =item B<< $metaclass->excludes_role($role_name) >> | ||||
| 983 | |||||
| 984 | A class excludes a role if it has already composed a role which | ||||
| 985 | excludes the named role. This tests both the class and its parents. | ||||
| 986 | |||||
| 987 | =item B<< $metaclass->add_attribute($attr_name, %params|$params) >> | ||||
| 988 | |||||
| 989 | This overrides the parent's method in order to allow the parameters to | ||||
| 990 | be provided as a hash reference. | ||||
| 991 | |||||
| 992 | =item B<< $metaclass->constructor_class($class_name) >> | ||||
| 993 | |||||
| 994 | =item B<< $metaclass->destructor_class($class_name) >> | ||||
| 995 | |||||
| 996 | These are the names of classes used when making a class immutable. These | ||||
| 997 | default to L<Moose::Meta::Method::Constructor> and | ||||
| 998 | L<Moose::Meta::Method::Destructor> respectively. These accessors are | ||||
| 999 | read-write, so you can use them to change the class name. | ||||
| 1000 | |||||
| 1001 | =item B<< $metaclass->error_class($class_name) >> | ||||
| 1002 | |||||
| 1003 | The name of the class used to throw errors. This defaults to | ||||
| 1004 | L<Moose::Error::Default>, which generates an error with a stacktrace | ||||
| 1005 | just like C<Carp::confess>. | ||||
| 1006 | |||||
| 1007 | =item B<< $metaclass->throw_error($message, %extra) >> | ||||
| 1008 | |||||
| 1009 | Throws the error created by C<create_error> using C<raise_error> | ||||
| 1010 | |||||
| 1011 | =back | ||||
| 1012 | |||||
| 1013 | =head1 BUGS | ||||
| 1014 | |||||
| 1015 | See L<Moose/BUGS> for details on reporting bugs. | ||||
| 1016 | |||||
| 1017 | =head1 AUTHOR | ||||
| 1018 | |||||
| 1019 | Moose is maintained by the Moose Cabal, along with the help of many contributors. See L<Moose/CABAL> and L<Moose/CONTRIBUTORS> for details. | ||||
| 1020 | |||||
| 1021 | =head1 COPYRIGHT AND LICENSE | ||||
| 1022 | |||||
| 1023 | This software is copyright (c) 2012 by Infinity Interactive, Inc.. | ||||
| 1024 | |||||
| 1025 | This is free software; you can redistribute it and/or modify it under | ||||
| 1026 | the same terms as the Perl 5 programming language system itself. | ||||
| 1027 | |||||
| 1028 | =cut | ||||
| 1029 | |||||
| 1030 | |||||
| 1031 | __END__ | ||||
# spent 6µs within Moose::Meta::Class::CORE:match which was called 6 times, avg 1µs/call:
# 6 times (6µs+0s) by Moose::Meta::Class::_process_attribute at line 693, avg 1µs/call | |||||
# spent 185µs within Moose::Meta::Class::CORE:subst which was called 120 times, avg 2µs/call:
# 120 times (185µs+0s) by Moose::Meta::Class::_base_metaclasses at line 622, avg 2µs/call |