Crop/Object/Warehouse/Lang/SQL/Query/Select/Node/Root.pm untested

filter: Statementstmt 0.0% 0 / 36 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 59 CC 3 SCAR 12.0
CC
3
Cov
0%
make_collection
6.0
parse_row
6.0
new
2.0
CRAP 3.3
1 package Crop::Object::Warehouse::Lang::SQL::Query::Select::Node::Root;
2 use base qw/ Crop::Object::Warehouse::Lang::SQL::Query::Select::Node /;
3  
4 =begin nd
5 Class: Crop::Object::Warehouse::Lang::SQL::Query::Select::Node::Root
6 Root node.
7 =cut
8  
9 use v5.14;
10 use warnings;
11  
12 use Crop::Error;
13 use Crop::Object::Constants;
14 use Crop::Object::Collection;
15  
16 use Crop::Debug;
17  
18 =begin nd
19 Variable: our %Attributes
20 Class members:
21  
22 object - Collection of root items; is the result of entire work of the 'All()' method.
23 =cut
24 our %Attributes = (
25 object => {mode => 'read'},
26 );
27  
28 =begin
29 Constructor: new (%in)
30 Initiate object store.
31
32 Returns:
33 $self - if ok
34 undef - otherwise
35 =cut
36 sub new {
37 my ($class, %in) = @_;
38
39 my $self = $class->SUPER::new(%in) or return warn "OBJECT|CRIT: Constructor of Node::Root fails";
40
41 $self->{object} = Crop::Object::Collection->new($in{class});
42
43 $self;
44 }
45  
46 =begin nd
47 Make a collection for $view.
48
49 Parameters:
50 $view - name of attribute
51 $item_class - collection class
52 =cut
53 sub make_collection {
54 my ($self, $view, $item_class) = @_;
55
56 $self->{current}{$view} = Crop::Object::Collection->new($item_class) unless $self->{current}{$view};
57 }
58  
59 =begin nd
60 Method: parse_row ($row)
61 Handle row of the raw data from database and put object to the right place.
62
63 Parameters:
64 $row - hashref to the entire row
65 =cut
66 sub parse_row {
67 my ($self, $row) = @_;
68
69 my $item = $self->{class}->new($row->{$self->{table_effective}})->Set_state(DWHLINK);
70 $item->_Is_key_defined or return;
71  
72 my $found_in_cache = $self->see_cache($item);
73
74 if ($found_in_cache) {
75 $item = $found_in_cache;
76 } else {
77 $self->{object}->Push($item);
78 }
79  
80 $self->{current} = $item;
81 }
82  
83 1;