File Coverage

blib/lib/Data/Sah/Compiler/perl/TH/obj.pm
Criterion Covered Total %
statement 29 29 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod 0 3 0.0
total 37 40 92.5


line stmt bran cond sub pod time code
1              
2             use 5.010;
3 2     2   37 use strict;
  2         6  
4 2     2   9 use warnings;
  2         5  
  2         44  
5 2     2   9 #use Log::Any '$log';
  2         4  
  2         51  
6              
7             use Mo qw(build default);
8 2     2   10 use Role::Tiny::With;
  2         4  
  2         11  
9 2     2   483  
  2         3  
  2         525  
10             extends 'Data::Sah::Compiler::perl::TH';
11             with 'Data::Sah::Type::obj';
12              
13             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
14             our $DATE = '2022-10-19'; # DATE
15             our $DIST = 'Data-Sah'; # DIST
16             our $VERSION = '0.914'; # VERSION
17              
18             my ($self, $cd) = @_;
19             my $c = $self->compiler;
20 17     17 0 34  
21 17         59 my $dt = $cd->{data_term};
22             $c->add_runtime_module($cd, 'Scalar::Util');
23 17         81 $cd->{_ccl_check_type} = "Scalar::Util::blessed($dt)";
24 17         51 }
25 17         68  
26             my ($self, $cd) = @_;
27             my $c = $self->compiler;
28             my $ct = $cd->{cl_term};
29 10     10 0 18 my $dt = $cd->{data_term};
30 10         24  
31 10         43 $c->add_ccl($cd, "$dt->can($ct)");
32 10         16 }
33              
34 10         35 my ($self, $cd) = @_;
35             my $c = $self->compiler;
36             my $ct = $cd->{cl_term};
37             my $dt = $cd->{data_term};
38 6     6 0 15  
39 6         19 $c->add_ccl($cd, "$dt->isa($ct)");
40 6         31 }
41 6         12  
42             1;
43 6         23 # ABSTRACT: perl's type handler for type "obj"
44              
45              
46             =pod
47              
48             =encoding UTF-8
49              
50             =head1 NAME
51              
52             Data::Sah::Compiler::perl::TH::obj - perl's type handler for type "obj"
53              
54             =head1 VERSION
55              
56             This document describes version 0.914 of Data::Sah::Compiler::perl::TH::obj (from Perl distribution Data-Sah), released on 2022-10-19.
57              
58             =for Pod::Coverage ^(clause_.+|superclause_.+)$
59              
60             =head1 HOMEPAGE
61              
62             Please visit the project's homepage at L<https://metacpan.org/release/Data-Sah>.
63              
64             =head1 SOURCE
65              
66             Source repository is at L<https://github.com/perlancar/perl-Data-Sah>.
67              
68             =head1 AUTHOR
69              
70             perlancar <perlancar@cpan.org>
71              
72             =head1 CONTRIBUTING
73              
74              
75             To contribute, you can send patches by email/via RT, or send pull requests on
76             GitHub.
77              
78             Most of the time, you don't need to build the distribution yourself. You can
79             simply modify the code, then test via:
80              
81             % prove -l
82              
83             If you want to build the distribution (e.g. to try to install it locally on your
84             system), you can install L<Dist::Zilla>,
85             L<Dist::Zilla::PluginBundle::Author::PERLANCAR>,
86             L<Pod::Weaver::PluginBundle::Author::PERLANCAR>, and sometimes one or two other
87             Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond
88             that are considered a bug and can be reported to me.
89              
90             =head1 COPYRIGHT AND LICENSE
91              
92             This software is copyright (c) 2022, 2021, 2020, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012 by perlancar <perlancar@cpan.org>.
93              
94             This is free software; you can redistribute it and/or modify it under
95             the same terms as the Perl 5 programming language system itself.
96              
97             =head1 BUGS
98              
99             Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Sah>
100              
101             When submitting a bug or request, please include a test-file or a
102             patch to an existing test-file that illustrates the bug or desired
103             feature.
104              
105             =cut