| 1 | package MooseX::Emulate::Class::Accessor::Fast::Meta::Accessor; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 10 | ▶ | use Moose; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | |||||||||||||||
| 5 | 10 | extends 'Moose::Meta::Method::Accessor'; | |||||||||||||
| 6 | |||||||||||||||
| 7 | 11 | ▶ | sub _generate_accessor_method { | ||||||||||||
|
Subroutine
_generate_accessor_method: called CC=1 SCAR=0.8
| |||||||||||||||
| 8 | 11 | my $attr = (shift)->associated_attribute; | |||||||||||||
| 9 | 0 | ▶ | return sub { | ||||||||||||
|
Subroutine
yar: not called CC=3 SCAR=14.2
Subroutine
__ANON__: called CC=3 SCAR=14.2
| |||||||||||||||
| 10 | 0 | my $self = shift; | |||||||||||||
| 11 | 0 | ▶ | $attr->set_value($self, $_[0]) if scalar(@_) == 1; | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 12 | 0 | ▶ | $attr->set_value($self, [@_]) if scalar(@_) > 1; | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 13 | 0 | $attr->get_value($self); | |||||||||||||
| 14 | 11 | }; | |||||||||||||
| 15 | } | ||||||||||||||
| 16 | |||||||||||||||
| 17 | 6 | ▶ | sub _generate_writer_method { | ||||||||||||
|
Subroutine
_generate_writer_method: called CC=1 SCAR=0.1
| |||||||||||||||
| 18 | 6 | my $attr = (shift)->associated_attribute; | |||||||||||||
| 19 | 1 | ▶ | return sub { | ||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.7
| |||||||||||||||
| 20 | 1 | my $self = shift; | |||||||||||||
| 21 | 1 | ▶ | $attr->set_value($self, $_[0]) if scalar(@_) == 1; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 22 | 1 | ▶ | $attr->set_value($self, [@_]) if scalar(@_) > 1; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 23 | 6 | }; | |||||||||||||
| 24 | } | ||||||||||||||
| 25 | |||||||||||||||
| 26 | # FIXME - this is shite, but it does work... | ||||||||||||||
| 27 | 0 | ▶ | sub _generate_accessor_method_inline { | ||||||||||||
|
Subroutine
_generate_accessor_method_inline: not called CC=2 SCAR=17.9
| |||||||||||||||
| 28 | 0 | my $attr = (shift)->associated_attribute; | |||||||||||||
| 29 | 0 | my $attr_name = $attr->name; | |||||||||||||
| 30 | 0 | my $meta_instance = $attr->associated_class->instance_metaclass; | |||||||||||||
| 31 | |||||||||||||||
| 32 | 0 | my $code = eval "sub { | |||||||||||||
| 33 | my \$self = shift; | ||||||||||||||
| 34 | \$self->{'$attr_name'} = \$_[0] if scalar(\@_) == 1; | ||||||||||||||
| 35 | \$self->{'$attr_name'} = [\@_] if scalar(\@_) > 1; | ||||||||||||||
| 36 | \$self->{'$attr_name'}; | ||||||||||||||
| 37 | }"; | ||||||||||||||
| 38 | 0 | ▶ | confess "Could not generate inline accessor because : $@" if $@; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 39 | |||||||||||||||
| 40 | 0 | return $code; | |||||||||||||
| 41 | } | ||||||||||||||
| 42 | |||||||||||||||
| 43 | { | ||||||||||||||
| 44 | 10 | my $meta = __PACKAGE__->meta; | |||||||||||||
| 45 | 10 | $meta->add_method(_generate_writer_method_inline => $meta->get_method('_generate_accessor_method_inline')); | |||||||||||||
| 46 | } | ||||||||||||||
| 47 | |||||||||||||||
| 48 | 10 | ▶ | no Moose; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 49 | |||||||||||||||
| 50 | 10 | 1; | |||||||||||||