File Coverage

blib/lib/Net/Braintree/AdvancedSearchFields.pm
Criterion Covered Total %
statement 23 30 76.6
branch 0 2 0.0
condition n/a
subroutine 10 17 58.8
pod 0 8 0.0
total 33 57 57.8


line stmt bran cond sub pod time code
1             {
2             package Net::Braintree::AdvancedSearchFields;
3 1     1   5 use Carp;
  1         2  
  1         70  
4 1     1   4 use Moose;
  1         1  
  1         6  
5              
6             has "metaclass" => (is => 'rw');
7              
8             sub field {
9 101     101 0 131 my ($self, $name, $node) = @_;
10 101         3470 $self->metaclass->add_attribute($name, is => 'rw', default => $node);
11             }
12              
13             sub is {
14 1     1 0 3 my ($self, $name) = @_;
15             $self->field($name, sub {
16 0     0   0 return Net::Braintree::IsNode->new(searcher => shift, name => $name);
17 1         5 });
18             }
19              
20             sub equality {
21 3     3 0 9 my ($self, $name) = @_;
22             $self->field($name, sub {
23 0     0   0 return Net::Braintree::EqualityNode->new(searcher => shift, name => $name);
24 3         16 });
25             }
26              
27             sub text {
28 60     60 0 125 my ($self, $name) = @_;
29             $self->field($name, sub {
30 0     0   0 return Net::Braintree::TextNode->new(searcher => shift, name => $name);
31 60         269 });
32             }
33              
34             sub key_value {
35 1     1 0 2 my ($self, $name) = @_;
36             $self->field($name, sub {
37 0     0   0 return Net::Braintree::KeyValueNode->new(searcher => shift, name => $name);
38 1         6 });
39             }
40              
41             sub range {
42 18     18 0 44 my ($self, $name) = @_;
43             $self->field($name, sub {
44 0     0   0 return Net::Braintree::RangeNode->new(searcher => shift, name => $name);
45 18         100 });
46             }
47              
48             sub multiple_values {
49 15     15 0 45 my ($self, $name, @allowed_values) = @_;
50             my $node = sub {
51 0 0   0   0 return Net::Braintree::MultipleValuesNode->new(
52             searcher => shift,
53             name => $name,
54             allowed_values => @allowed_values ? [@allowed_values] : undef)
55 15         61 };
56 15         35 $self->field($name, $node);
57             }
58              
59             sub partial_match {
60 3     3 0 14 my ($self, $name) = @_;
61             $self->field($name, sub {
62 0     0     return Net::Braintree::PartialMatchNode->new(searcher => shift, name => $name);
63 3         17 });
64             }
65              
66             1;
67             }