File Coverage

lib/WebService/Braintree/AdvancedSearchFields.pm
Criterion Covered Total %
statement 28 35 80.0
branch 0 2 0.0
condition n/a
subroutine 12 19 63.1
pod 0 8 0.0
total 40 64 62.5


line stmt bran cond sub pod time code
1             package WebService::Braintree::AdvancedSearchFields;
2             $WebService::Braintree::AdvancedSearchFields::VERSION = '0.94';
3 20     20   393 use 5.010_001;
  20         60  
4 20     20   100 use strictures 1;
  20         136  
  20         884  
5              
6 20     20   1934 use Carp;
  20         35  
  20         1137  
7 20     20   103 use Moose;
  20         35  
  20         120  
8              
9             has "metaclass" => (is => 'rw');
10              
11             sub field {
12 2020     2020 0 3802 my ($self, $name, $node) = @_;
13 2020         63381 $self->metaclass->add_attribute($name, is => 'rw', default => $node);
14             }
15              
16             sub is {
17 20     20 0 63 my ($self, $name) = @_;
18             $self->field($name, sub {
19 0     0   0 return WebService::Braintree::IsNode->new(searcher => shift, name => $name);
20 20         110 });
21             }
22              
23             sub equality {
24 60     60 0 210 my ($self, $name) = @_;
25             $self->field($name, sub {
26 0     0   0 return WebService::Braintree::EqualityNode->new(searcher => shift, name => $name);
27 60         354 });
28             }
29              
30             sub text {
31 1200     1200 0 3052 my ($self, $name) = @_;
32             $self->field($name, sub {
33 0     0   0 return WebService::Braintree::TextNode->new(searcher => shift, name => $name);
34 1200         5732 });
35             }
36              
37             sub key_value {
38 20     20 0 88 my ($self, $name) = @_;
39             $self->field($name, sub {
40 0     0   0 return WebService::Braintree::KeyValueNode->new(searcher => shift, name => $name);
41 20         121 });
42             }
43              
44             sub range {
45 360     360 0 1016 my ($self, $name) = @_;
46             $self->field($name, sub {
47 0     0   0 return WebService::Braintree::RangeNode->new(searcher => shift, name => $name);
48 360         1734 });
49             }
50              
51             sub multiple_values {
52 300     300 0 1104 my ($self, $name, @allowed_values) = @_;
53             my $node = sub {
54 0 0   0   0 return WebService::Braintree::MultipleValuesNode->new(
55             searcher => shift,
56             name => $name,
57             allowed_values => @allowed_values ? [@allowed_values] : undef,
58             );
59 300         1213 };
60 300         1148 $self->field($name, $node);
61             }
62              
63             sub partial_match {
64 60     60 0 214 my ($self, $name) = @_;
65             $self->field($name, sub {
66 0     0     return WebService::Braintree::PartialMatchNode->new(searcher => shift, name => $name);
67 60         337 });
68             }
69              
70             __PACKAGE__->meta->make_immutable;
71              
72             1;
73             __END__