line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Specio::Constraint::AnyDoes; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
23
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
106
|
|
4
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
205
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.47'; |
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
19
|
use Role::Tiny::With; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
167
|
|
9
|
3
|
|
|
3
|
|
17
|
use Scalar::Util (); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
60
|
|
10
|
3
|
|
|
3
|
|
16
|
use Specio::Helpers qw( perlstring ); |
|
3
|
|
|
|
|
269
|
|
|
3
|
|
|
|
|
311
|
|
11
|
3
|
|
|
3
|
|
452
|
use Specio::Library::Builtins; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
30
|
|
12
|
3
|
|
|
3
|
|
20
|
use Specio::OO; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
190
|
|
13
|
|
|
|
|
|
|
|
14
|
3
|
|
|
3
|
|
554
|
use Specio::Constraint::Role::DoesType; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
613
|
|
15
|
|
|
|
|
|
|
with 'Specio::Constraint::Role::DoesType'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
{ |
18
|
|
|
|
|
|
|
my $Defined = t('Defined'); |
19
|
4
|
|
|
4
|
|
47
|
sub _build_parent {$Defined} |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
{ |
23
|
|
|
|
|
|
|
my $_inline_generator = sub { |
24
|
|
|
|
|
|
|
my $self = shift; |
25
|
|
|
|
|
|
|
my $val = shift; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
return sprintf( <<'EOF', ($val) x 8, perlstring( $self->role ) ); |
28
|
|
|
|
|
|
|
( |
29
|
|
|
|
|
|
|
( |
30
|
|
|
|
|
|
|
Scalar::Util::blessed(%s) || ( |
31
|
|
|
|
|
|
|
!ref(%s) |
32
|
|
|
|
|
|
|
&& defined(%s) |
33
|
|
|
|
|
|
|
&& length(%s) |
34
|
|
|
|
|
|
|
&& %s !~ /\A |
35
|
|
|
|
|
|
|
\s* |
36
|
|
|
|
|
|
|
-?[0-9]+(?:\.[0-9]+)? |
37
|
|
|
|
|
|
|
(?:[Ee][\-+]?[0-9]+)? |
38
|
|
|
|
|
|
|
\s* |
39
|
|
|
|
|
|
|
\z/xs |
40
|
|
|
|
|
|
|
&& ref( \%s ) ne 'GLOB' |
41
|
|
|
|
|
|
|
) |
42
|
|
|
|
|
|
|
) |
43
|
|
|
|
|
|
|
&& %s->can('does') |
44
|
|
|
|
|
|
|
&& %s->does(%s) |
45
|
|
|
|
|
|
|
) |
46
|
|
|
|
|
|
|
EOF |
47
|
|
|
|
|
|
|
}; |
48
|
|
|
|
|
|
|
|
49
|
4
|
|
|
4
|
|
149
|
sub _build_inline_generator {$_inline_generator} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) |
53
|
4
|
|
|
4
|
|
11
|
sub _allow_classes {1} |
54
|
|
|
|
|
|
|
## use critic |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
__PACKAGE__->_ooify; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# ABSTRACT: A class for constraints which require a class name or an object that does a specific role |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__END__ |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=pod |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=encoding UTF-8 |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 NAME |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Specio::Constraint::AnyDoes - A class for constraints which require a class name or an object that does a specific role |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 VERSION |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
version 0.47 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 SYNOPSIS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
my $type = Specio::Constraint::AnyDoes->new(...); |
79
|
|
|
|
|
|
|
print $type->role; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 DESCRIPTION |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This is a specialized type constraint class for types which require a class |
84
|
|
|
|
|
|
|
name or an object that does a specific role. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 API |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This class provides all of the same methods as L<Specio::Constraint::Simple>, |
89
|
|
|
|
|
|
|
with a few differences: |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 Specio::Constraint::AnyDoes->new( ... ) |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
The C<parent> parameter is ignored if it passed, as it is always set to the |
94
|
|
|
|
|
|
|
C<Defined> type. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
The C<inline_generator> and C<constraint> parameters are also ignored. This |
97
|
|
|
|
|
|
|
class provides its own default inline generator subroutine reference. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
This class overrides the C<message_generator> default if none is provided. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Finally, this class requires an additional parameter, C<role>. This must be a |
102
|
|
|
|
|
|
|
single role name. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 $any_isa->role |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Returns the role name passed to the constructor. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 ROLES |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
This class does the L<Specio::Constraint::Role::DoesType>, |
111
|
|
|
|
|
|
|
L<Specio::Constraint::Role::Interface>, L<Specio::Role::Inlinable>, and |
112
|
|
|
|
|
|
|
L<MooseX::Clone> roles. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 SUPPORT |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Bugs may be submitted at L<https://github.com/houseabsolute/Specio/issues>. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 SOURCE |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
The source code repository for Specio can be found at L<https://github.com/houseabsolute/Specio>. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 AUTHOR |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
This software is Copyright (c) 2012 - 2021 by Dave Rolsky. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
This is free software, licensed under: |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
The full text of the license can be found in the |
137
|
|
|
|
|
|
|
F<LICENSE> file included with this distribution. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |