File Coverage

blib/lib/Intertangle/Punchcard/Backend/Kiwisolver/Symbolic.pm
Criterion Covered Total %
statement 34 36 94.4
branch 7 10 70.0
condition 2 3 66.6
subroutine 8 8 100.0
pod 2 2 100.0
total 53 59 89.8


line stmt bran cond sub pod time code
1 1     1   6 use Renard::Incunabula::Common::Setup;
  1         2  
  1         11  
2             package Intertangle::Punchcard::Backend::Kiwisolver::Symbolic;
3             # ABSTRACT: Kiwisolver variable
4             $Intertangle::Punchcard::Backend::Kiwisolver::Symbolic::VERSION = '0.001';
5 1     1   6433 use Mu;
  1         2  
  1         9  
6 1     1   871 use Intertangle::API::Kiwisolver;
  1         2  
  1         26  
7 1     1   5 use Renard::Incunabula::Common::Types qw(InstanceOf);
  1         2  
  1         15  
8 1     1   689 use overload nomethod => \&_delegate_op;
  1         2  
  1         7  
9              
10             has name => ( is => 'ro', predicate => 1 );
11              
12             has _delegate => (
13             is => 'ro',
14             isa => (
15             InstanceOf['Intertangle::API::Kiwisolver::Variable']
16             | InstanceOf['Intertangle::API::Kiwisolver::Term']
17             | InstanceOf['Intertangle::API::Kiwisolver::Expression']
18             | InstanceOf['Intertangle::API::Kiwisolver::Constraint']
19             ),
20             default => method() {
21             Intertangle::API::Kiwisolver::Variable->new;
22             },
23             );
24              
25 60     60 1 1595 method BUILD() {
  60         74  
26 60 100       179 if( $self->has_name ) {
27 17         103 $self->_delegate->setName( $self->name );
28             }
29             }
30              
31 43     43   222 method _delegate_op($other, $inv, $meth) {
  43         71  
  43         51  
32 43         93 my $op = overload::Method($self->_delegate, $meth);
33 43 50       1501 die "Operator $meth not available" unless defined $op;
34 43 100 66     368 my $return = $op->($self->_delegate, defined $other && ref $other ? $other->_delegate : $other , $inv );
35              
36 43 50       105 if( $meth eq '""') {
37 0         0 return $return;
38             }
39              
40 43         88 my $return_wrapper;
41 43         721 $return_wrapper = Intertangle::Punchcard::Backend::Kiwisolver::Symbolic->new(
42             _delegate => $return,
43             );
44              
45 43         136 $return_wrapper;
46             }
47              
48 12     12 1 575 method value($value = undef) {
  12         19  
  12         13  
49 12 50       19 if( defined $value ) {
50 0         0 $self->_delegate->setValue( $value );
51             } else {
52 12         41 $self->_delegate->value;
53             }
54             }
55              
56             with qw(Intertangle::Punchcard::Data::Role::Variable);
57              
58             1;
59              
60             __END__
61              
62             =pod
63              
64             =encoding UTF-8
65              
66             =head1 NAME
67              
68             Intertangle::Punchcard::Backend::Kiwisolver::Symbolic - Kiwisolver variable
69              
70             =head1 VERSION
71              
72             version 0.001
73              
74             =head1 EXTENDS
75              
76             =over 4
77              
78             =item * L<Moo::Object>
79              
80             =back
81              
82             =head1 CONSUMES
83              
84             =over 4
85              
86             =item * L<Intertangle::Punchcard::Data::Role::HasValue>
87              
88             =item * L<Intertangle::Punchcard::Data::Role::Variable>
89              
90             =back
91              
92             =head1 ATTRIBUTES
93              
94             =head2 name
95              
96             Name for variable.
97              
98             =head1 METHODS
99              
100             =head2 C<has_name>
101              
102             Predicate for C<name>.
103              
104             =head2 BUILD
105              
106             =head2 value
107              
108             Set or get value for variable.
109              
110             =head1 AUTHOR
111              
112             Zakariyya Mughal <zmughal@cpan.org>
113              
114             =head1 COPYRIGHT AND LICENSE
115              
116             This software is copyright (c) 2019 by Zakariyya Mughal.
117              
118             This is free software; you can redistribute it and/or modify it under
119             the same terms as the Perl 5 programming language system itself.
120              
121             =cut