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