line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MouseX::SingletonMethod::Role; |
2
|
3
|
|
|
3
|
|
2517
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
127
|
|
3
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
361
|
|
4
|
3
|
|
|
3
|
|
2379
|
use Mouse::Role; |
|
3
|
|
|
|
|
3163
|
|
|
3
|
|
|
|
|
29
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
my $singleton = sub { |
7
|
|
|
|
|
|
|
my $self = shift; |
8
|
|
|
|
|
|
|
my $methods = shift || {}; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $meta = $self->meta->create_anon_class( |
11
|
|
|
|
|
|
|
superclasses => [ $self->meta->name ], |
12
|
|
|
|
|
|
|
methods => $methods, |
13
|
|
|
|
|
|
|
); |
14
|
6
|
|
|
6
|
|
47
|
$meta->add_method( meta => sub {$meta} ); |
|
|
|
|
6
|
|
|
|
|
|
|
|
6
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
bless $self, $meta->name; |
17
|
|
|
|
|
|
|
}; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub become_singleton { |
20
|
2
|
|
|
2
|
1
|
9297
|
$_[0]->$singleton; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub add_singleton_method { |
24
|
2
|
|
|
2
|
1
|
3399
|
$_[0]->$singleton( { $_[1] => $_[2] } ); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub add_singleton_methods { |
28
|
2
|
|
|
2
|
1
|
25
|
my $self = shift; |
29
|
2
|
|
|
|
|
10
|
$self->$singleton( {@_} ); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
3
|
|
|
3
|
|
1320
|
no Mouse::Role; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
16
|
|
33
|
|
|
|
|
|
|
1; |
34
|
|
|
|
|
|
|
__END__ |