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.25";
4              
5 11     11   67 use strict;
  11         24  
  11         250  
6 11     11   52 use warnings;
  11         29  
  11         224  
7              
8 11     11   2177 use App::RecordStream::Aggregator::MapReduce;
  11         20  
  11         226  
9 11     11   2154 use App::RecordStream::DomainLanguage::Valuation::KeySpec;
  11         29  
  11         251  
10              
11 11     11   50 use base 'App::RecordStream::Aggregator::MapReduce';
  11         17  
  11         2515  
12              
13             sub new
14             {
15 12     12 0 433 my $class = shift;
16 12         38 my $field = shift;
17              
18 12         104 return new_from_valuation($class, App::RecordStream::DomainLanguage::Valuation::KeySpec->new($field));
19             }
20              
21             sub new_from_valuation
22             {
23 37     37 0 68 my $class = shift;
24 37         68 my $valuation = shift;
25              
26 37         114 my $this =
27             {
28             'valuation' => $valuation,
29             };
30 37         77 bless $this, $class;
31              
32 37         119 return $this;
33             }
34              
35             sub map
36             {
37 98     98 0 192 my ($this, $record) = @_;
38              
39 98 50       255 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         270 return $this->map_field($this->{'valuation'}->evaluate_record($record));
45             }
46              
47             sub map_field
48             {
49 65     65 0 141 my ($this, $value) = @_;
50              
51 65         139 return $value;
52             }
53              
54             sub argct
55             {
56 5     5 0 15 return 1;
57             }
58              
59             1;