SingletonMethod/Role.pm

filter: Statementstmt 100% 20 / 20 Branchbran n/a Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 8 / 8 Podpod 100% 3 / 3 totaltotal 100% 34 / 34 CC 2 SCAR 2.0
CC
2
Cov
100%
__ANON__
2.0
BEGIN
1.0
__ANON__
1.0
CRAP 1.2
↑ Summary SingletonMethod.pm »
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() || {}
l!l
42
MC/DC100%1/1
shift() || {}
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
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__
↑ Summary SingletonMethod.pm »