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