| 1 | 385 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 385 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | package Moose::Meta::Attribute::Native; | ||||||||||
| 4 | 358 | our $VERSION = '2.4001'; | |||||||||
| 5 | |||||||||||
| 6 | 385 | ▶ | use Module::Runtime 'require_module'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 358 | my @trait_names = qw(Bool Counter Number String Array Hash Code); | |||||||||
| 9 | |||||||||||
| 10 | 358 | for my $trait_name (@trait_names) { | |||||||||
| 11 | 2506 | my $trait_class = "Moose::Meta::Attribute::Native::Trait::$trait_name"; | |||||||||
| 12 | 2506 | my $meta = Class::MOP::Class->initialize( | |||||||||
| 13 | "Moose::Meta::Attribute::Custom::Trait::$trait_name" | ||||||||||
| 14 | ); | ||||||||||
| 15 | |||||||||||
| 16 | 2506 | ▶ | if ($meta->find_method_by_name('register_implementation')) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | 0 | my $class = $meta->name->register_implementation; | |||||||||
| 18 | 0 | die "An implementation for $trait_name already exists " . | |||||||||
| 19 | "(found '$class' when trying to register '$trait_class')" | ||||||||||
| 20 | } | ||||||||||
| 21 | 54 | ▶ | $meta->add_method(register_implementation => sub { | ||||||||
|
Subroutine
register_implementation: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 22 | # resolve_metatrait_alias will load classes anyway, but throws away | ||||||||||
| 23 | # their error message; we WANT to die if there's a problem | ||||||||||
| 24 | 54 | require_module($trait_class); | |||||||||
| 25 | 54 | return $trait_class; | |||||||||
| 26 | 2506 | }); | |||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 358 | 1; | |||||||||
| 30 | |||||||||||
| 31 | # ABSTRACT: Delegate to native Perl types | ||||||||||
| 32 | |||||||||||
| 33 | __END__ | ||||||||||