File Coverage

blib/lib/WebService/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             package WebService::Braintree::AdvancedSearchFields;
2             $WebService::Braintree::AdvancedSearchFields::VERSION = '0.93';
3 1     1   10 use Carp;
  1         3  
  1         113  
4 1     1   11 use Moose;
  1         4  
  1         11  
5              
6             has "metaclass" => (is => 'rw');
7              
8             sub field {
9 101     101 0 342 my ($self, $name, $node) = @_;
10 101         4857 $self->metaclass->add_attribute($name, is => 'rw', default => $node);
11             }
12              
13             sub is {
14 1     1 0 6 my ($self, $name) = @_;
15             $self->field($name, sub {
16 0     0   0 return WebService::Braintree::IsNode->new(searcher => shift, name => $name);
17 1         10 });
18             }
19              
20             sub equality {
21 3     3 0 19 my ($self, $name) = @_;
22             $self->field($name, sub {
23 0     0   0 return WebService::Braintree::EqualityNode->new(searcher => shift, name => $name);
24 3         35 });
25             }
26              
27             sub text {
28 60     60 0 282 my ($self, $name) = @_;
29             $self->field($name, sub {
30 0     0   0 return WebService::Braintree::TextNode->new(searcher => shift, name => $name);
31 60         551 });
32             }
33              
34             sub key_value {
35 1     1 0 6 my ($self, $name) = @_;
36             $self->field($name, sub {
37 0     0   0 return WebService::Braintree::KeyValueNode->new(searcher => shift, name => $name);
38 1         9 });
39             }
40              
41             sub range {
42 18     18 0 74 my ($self, $name) = @_;
43             $self->field($name, sub {
44 0     0   0 return WebService::Braintree::RangeNode->new(searcher => shift, name => $name);
45 18         138 });
46             }
47              
48             sub multiple_values {
49 15     15 0 79 my ($self, $name, @allowed_values) = @_;
50             my $node = sub {
51 0 0   0   0 return WebService::Braintree::MultipleValuesNode->new(
52             searcher => shift,
53             name => $name,
54             allowed_values => @allowed_values ? [@allowed_values] : undef)
55 15         91 };
56 15         69 $self->field($name, $node);
57             }
58              
59             sub partial_match {
60 3     3 0 20 my ($self, $name) = @_;
61             $self->field($name, sub {
62 0     0     return WebService::Braintree::PartialMatchNode->new(searcher => shift, name => $name);
63 3         30 });
64             }
65              
66             __PACKAGE__->meta->make_immutable;
67             1;
68