line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooX::MouseTypeConstraints; |
2
|
3
|
|
|
3
|
|
50175
|
use 5.008001; |
|
3
|
|
|
|
|
12
|
|
3
|
3
|
|
|
3
|
|
17
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
74
|
|
4
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
134
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
1475
|
use B::Hooks::EndOfScope; |
|
3
|
|
|
|
|
25495
|
|
|
3
|
|
|
|
|
22
|
|
9
|
3
|
|
|
3
|
|
1440
|
use Mouse::Util::TypeConstraints (); |
|
3
|
|
|
|
|
38680
|
|
|
3
|
|
|
|
|
482
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub import { |
12
|
5
|
|
|
5
|
|
26937
|
my $class = shift; |
13
|
5
|
|
|
|
|
15
|
my $target = caller; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
on_scope_end { |
16
|
5
|
100
|
|
5
|
|
1072
|
my $has = $target->can('has') |
17
|
|
|
|
|
|
|
or die q|Moo's internal DSL keyword `has` is not found. (perhaps you forgot to load "Moo"?)|; |
18
|
|
|
|
|
|
|
my $code = sub { |
19
|
4
|
|
|
4
|
|
21705
|
my ($name, %args) = @_; |
20
|
4
|
50
|
33
|
|
|
35
|
if (exists $args{isa} && !ref $args{isa}) { |
21
|
4
|
|
|
|
|
50
|
my $type = Mouse::Util::TypeConstraints::find_or_create_isa_type_constraint($args{isa}); |
22
|
4
|
|
|
|
|
312
|
$args{isa} = _generate_isa($type); |
23
|
|
|
|
|
|
|
} |
24
|
4
|
|
|
|
|
18
|
@_ = ($name, %args); |
25
|
4
|
|
|
|
|
22
|
goto $has; |
26
|
4
|
|
|
|
|
21
|
}; |
27
|
|
|
|
|
|
|
|
28
|
4
|
|
|
|
|
12
|
my $glob = "${target}::has"; |
29
|
|
|
|
|
|
|
{ |
30
|
3
|
|
|
3
|
|
27
|
no strict qw/refs/; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
106
|
|
|
4
|
|
|
|
|
8
|
|
31
|
3
|
|
|
3
|
|
18
|
no warnings qw/prototype redefine/; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
608
|
|
32
|
4
|
|
|
|
|
9
|
*{$glob} = $code; |
|
4
|
|
|
|
|
21
|
|
33
|
|
|
|
|
|
|
}; |
34
|
5
|
|
|
|
|
45
|
}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _generate_isa { |
38
|
4
|
|
|
4
|
|
7
|
my $type = shift; |
39
|
4
|
100
|
|
|
|
37
|
if ($type->has_coercion) { |
40
|
|
|
|
|
|
|
return sub { |
41
|
3
|
100
|
|
3
|
|
2800
|
die $type->get_message(@_) unless $type->check($type->coerce(@_)); |
42
|
1
|
|
|
|
|
6
|
}; |
43
|
|
|
|
|
|
|
} else { |
44
|
|
|
|
|
|
|
return sub { |
45
|
8
|
100
|
|
8
|
|
8214
|
die $type->get_message(@_) unless $type->check(@_); |
46
|
3
|
|
|
|
|
21
|
}; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
__END__ |