File Coverage

blib/lib/App/RecordStream/Aggregator/MapReduce/Field.pm
Criterion Covered Total %
statement 29 30 96.6
branch 1 2 50.0
condition n/a
subroutine 10 10 100.0
pod 0 5 0.0
total 40 47 85.1


line stmt bran cond sub pod time code
1             package App::RecordStream::Aggregator::MapReduce::Field;
2              
3             our $VERSION = "4.0.23";
4              
5 11     11   69 use strict;
  11         22  
  11         320  
6 11     11   55 use warnings;
  11         23  
  11         870  
7              
8 11     11   2167 use App::RecordStream::Aggregator::MapReduce;
  11         42  
  11         226  
9 11     11   1965 use App::RecordStream::DomainLanguage::Valuation::KeySpec;
  11         26  
  11         240  
10              
11 11     11   53 use base 'App::RecordStream::Aggregator::MapReduce';
  11         21  
  11         2339  
12              
13             sub new
14             {
15 12     12 0 104 my $class = shift;
16 12         26 my $field = shift;
17              
18 12         82 return new_from_valuation($class, App::RecordStream::DomainLanguage::Valuation::KeySpec->new($field));
19             }
20              
21             sub new_from_valuation
22             {
23 37     37 0 84 my $class = shift;
24 37         76 my $valuation = shift;
25              
26 37         103 my $this =
27             {
28             'valuation' => $valuation,
29             };
30 37         84 bless $this, $class;
31              
32 37         131 return $this;
33             }
34              
35             sub map
36             {
37 98     98 0 232 my ($this, $record) = @_;
38              
39 98 50       297 if(!defined($this->{'valuation'}))
40             {
41             # oopsie, consider missing/undef fields not to count and return the empty cookie
42 0         0 return undef;
43             }
44 98         329 return $this->map_field($this->{'valuation'}->evaluate_record($record));
45             }
46              
47             sub map_field
48             {
49 65     65 0 145 my ($this, $value) = @_;
50              
51 65         213 return $value;
52             }
53              
54             sub argct
55             {
56 5     5 0 16 return 1;
57             }
58              
59             1;