File Coverage

blib/lib/Specio/Constraint/ObjectIsa.pm
Criterion Covered Total %
statement 27 27 100.0
branch n/a
condition n/a
subroutine 11 11 100.0
pod n/a
total 38 38 100.0


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