line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MouseX::SingletonMethod::Role; |
2
|
3
|
|
|
3
|
|
2282
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
123
|
|
3
|
3
|
|
|
3
|
|
19
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
87
|
|
4
|
3
|
|
|
3
|
|
2453
|
use Mouse::Role; |
|
3
|
|
|
|
|
2970
|
|
|
3
|
|
|
|
|
27
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my $singleton = sub { |
9
|
|
|
|
|
|
|
my $self = shift; |
10
|
|
|
|
|
|
|
my $methods = shift || {}; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $meta = $self->meta->create_anon_class( |
13
|
|
|
|
|
|
|
superclasses => [ $self->meta->name ], |
14
|
|
|
|
|
|
|
methods => $methods, |
15
|
|
|
|
|
|
|
); |
16
|
6
|
|
|
6
|
|
46
|
$meta->add_method( meta => sub {$meta} ); |
|
|
|
|
6
|
|
|
|
|
|
|
|
6
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
bless $self, $meta->name; |
19
|
|
|
|
|
|
|
}; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub become_singleton { |
22
|
2
|
|
|
2
|
1
|
16107
|
$_[0]->$singleton; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub add_singleton_method { |
26
|
2
|
|
|
2
|
1
|
3124
|
$_[0]->$singleton( { $_[1] => $_[2] } ); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub add_singleton_methods { |
30
|
2
|
|
|
2
|
1
|
23
|
my $self = shift; |
31
|
2
|
|
|
|
|
8
|
$self->$singleton( {@_} ); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
3
|
|
|
3
|
|
1298
|
no Mouse::Role; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
16
|
|
35
|
|
|
|
|
|
|
1; |
36
|
|
|
|
|
|
|
__END__ |