| 1 | package MooseX::SingletonMethod::Role; | ||||||||||||
| 2 | 4 | ▶ | use Moose::Role; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | |||||||||||||
| 4 | 4 | our $VERSION = '0.03'; | |||||||||||
| 5 | |||||||||||||
| 6 | 6 | ▶ | my $singleton = sub { | ||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||
| 7 | 6 | my $self = shift; | |||||||||||
| 8 | 6 | ▶ | my $methods = shift || {}; | ||||||||||
|
Condition100%2/2
shift() || {}
MC/DC100%1/1
shift() || {}
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||
| 9 | |||||||||||||
| 10 | 6 | my $meta = $self->meta->create_anon_class( | |||||||||||
| 11 | superclasses => [ $self->meta->name ], | ||||||||||||
| 12 | methods => $methods, | ||||||||||||
| 13 | ); | ||||||||||||
| 14 | |||||||||||||
| 15 | 6 | ▶ | $meta->add_method( meta => sub { $meta } ); | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
meta: called CC=1 SCAR=0.0
| |||||||||||||
| 16 | 6 | $meta->rebless_instance( $self ); | |||||||||||
| 17 | 4 | }; | |||||||||||
| 18 | |||||||||||||
| 19 | 2 | ▶ | sub become_singleton { $_[0]->$singleton } | ||||||||||
|
Subroutine
become_singleton: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 20 | |||||||||||||
| 21 | 2 | ▶ | sub add_singleton_method { $_[0]->$singleton({ $_[1] => $_[2] }) } | ||||||||||
|
Subroutine
add_singleton_method: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 22 | |||||||||||||
| 23 | 2 | ▶ | sub add_singleton_methods { | ||||||||||
|
Subroutine
add_singleton_methods: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 24 | 2 | my $self = shift; | |||||||||||
| 25 | 2 | $self->$singleton({ @_ }); | |||||||||||
| 26 | } | ||||||||||||
| 27 | |||||||||||||
| 28 | |||||||||||||
| 29 | 4 | ▶ | no Moose::Role; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 30 | 4 | 1; | |||||||||||
| 31 | |||||||||||||
| 32 | |||||||||||||
| 33 | |||||||||||||
| 34 | __END__ | ||||||||||||