line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooX::Should; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: optional type restrictions for Moo attributes |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
220339
|
use Moo (); |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
36
|
|
6
|
2
|
|
|
2
|
|
762
|
use Moo::Role (); |
|
2
|
|
|
|
|
13908
|
|
|
2
|
|
|
|
|
41
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
341
|
use Devel::StrictMode; |
|
2
|
|
|
|
|
355
|
|
|
2
|
|
|
|
|
328
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = 'v0.1.2'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub import { |
13
|
2
|
|
|
2
|
|
14
|
my ($class) = @_; |
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
|
|
8
|
my $target = caller; |
16
|
|
|
|
|
|
|
|
17
|
2
|
50
|
|
|
|
63
|
my $installer = |
18
|
|
|
|
|
|
|
$target->isa("Moo::Object") |
19
|
|
|
|
|
|
|
? \&Moo::_install_tracked |
20
|
|
|
|
|
|
|
: \&Moo::Role::install_tracked; |
21
|
|
|
|
|
|
|
|
22
|
2
|
50
|
|
|
|
14
|
if ( my $has = $target->can('has') ) { |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $wrapper = sub { |
25
|
4
|
|
|
4
|
|
209838
|
my ( $name, %args ) = @_; |
26
|
|
|
|
|
|
|
|
27
|
4
|
50
|
|
|
|
22
|
if ( my $should = delete $args{should} ) { |
28
|
4
|
|
|
|
|
32
|
$args{isa} = $should if STRICT; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
4
|
|
|
|
|
19
|
return $has->( $name => %args ); |
32
|
2
|
|
|
|
|
7
|
}; |
33
|
|
|
|
|
|
|
|
34
|
2
|
|
|
|
|
6
|
$installer->( $target, "has", $wrapper ); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |