line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooX::Should; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: optional type restrictions for Moo attributes |
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
455605
|
use version 0.77 (); |
|
3
|
|
|
|
|
6172
|
|
|
3
|
|
|
|
|
88
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
22
|
use Moo (); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
40
|
|
8
|
3
|
|
|
3
|
|
2035
|
use Moo::Role (); |
|
3
|
|
|
|
|
27937
|
|
|
3
|
|
|
|
|
237
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $USE_MOO_UTILS; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
BEGIN { |
13
|
3
|
50
|
|
3
|
|
318
|
if( version->parse( Moo->VERSION ) >= version->parse('2.003006') ) { |
14
|
0
|
|
|
|
|
0
|
$USE_MOO_UTILS = 1; |
15
|
0
|
|
|
|
|
0
|
require Moo::_Utils; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
3
|
|
|
3
|
|
1430
|
use Devel::StrictMode; |
|
3
|
|
|
|
|
972
|
|
|
3
|
|
|
|
|
782
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = 'v0.1.4'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub import { |
25
|
4
|
|
|
4
|
|
1086
|
my ($class) = @_; |
26
|
|
|
|
|
|
|
|
27
|
4
|
|
|
|
|
24
|
my $target = caller; |
28
|
|
|
|
|
|
|
|
29
|
4
|
50
|
|
|
|
177
|
my $has = $target->can('has') or return; |
30
|
|
|
|
|
|
|
|
31
|
4
|
100
|
|
|
|
42
|
my $installer = |
|
|
50
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$USE_MOO_UTILS |
33
|
|
|
|
|
|
|
? \&Moo::_Utils::_install_tracked |
34
|
|
|
|
|
|
|
: $target->isa("Moo::Object") |
35
|
|
|
|
|
|
|
? \&Moo::_install_tracked |
36
|
|
|
|
|
|
|
: \&Moo::Role::_install_tracked; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $wrapper = sub { |
39
|
7
|
|
|
7
|
|
417126
|
my ( $name, %args ) = @_; |
40
|
|
|
|
|
|
|
|
41
|
7
|
|
|
|
|
18
|
if (STRICT) { |
42
|
|
|
|
|
|
|
$args{isa} = delete $args{should} if exists $args{should} |
43
|
7
|
50
|
|
|
|
40
|
} else { |
44
|
|
|
|
|
|
|
delete $arg{should} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
7
|
|
|
|
|
38
|
return $has->( $name => %args ); |
48
|
4
|
|
|
|
|
20
|
}; |
49
|
|
|
|
|
|
|
|
50
|
4
|
|
|
|
|
19
|
$installer->( $target, "has", $wrapper ); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__END__ |