JsonSQL/Param/Tables.pm

filter: Statementstmt 89.4% 34 / 38 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 88.2% 45 / 51 CC 4 SCAR 8.5
CC
4
Cov
86%
new
4.4
BEGIN
1.0
BEGIN
1.0
CRAP 2.3
« JsonSQL/Param/Joins.pm ↑ Summary JsonSQL/Param/Conditions/LogicCondition.pm »
1 # ABSTRACT: JsonSQL::Param::Tables object. Stores an array of JsonSQL::Param::Table objects to use for constructing JsonSQL::Query objects.
2  
3  
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 package JsonSQL::Param::Tables;
10  
11 1 our $VERSION = '0.4'; # VERSION
12  
13 1 ▶use JsonSQL::Param::Table;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use JsonSQL::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16  
17  
18 sub new {
19 4 ▶ my ( $class, $tablesarrayref, $queryObj ) = @_;
Subroutine new: called CC=4 SCAR=14.8
Pod documented
20
21 4 my $self = [];
22 4 my @table_errors;
23
24 4 for my $tablehashref ( @{ $tablesarrayref } ) {
25 4 my $tableObj = JsonSQL::Param::Table->new($tablehashref, $queryObj);
26 4 ▶ if ( eval { $tableObj->is_error } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { $tableObj->is_error } }) { } 0 4 4
27 0 push(@table_errors, "Error creating table $tablehashref->{table}: $tableObj->{message}");
28 } else {
29 4 push (@{ $self }, $tableObj);
30 }
31 }
32
33 4 ▶ if ( @table_errors ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@table_errors) { } 0 4 4
34 0 my $err = "Could not parse all table objects: \n\t";
35 0 $err .= join("\n\t", @table_errors);
36 0 return JsonSQL::Error->new("invalid_tables", $err);
37 } else {
38 4 bless $self, $class;
39 4 return $self;
40 }
41 }
42  
43  
44 sub get_tables {
45 3 ▶ my ( $self, $queryObj ) = @_;
Subroutine get_tables: called CC=1 SCAR=0.0
Pod documented
46
47 3 my @tablesArray = map { $_->get_table_param($queryObj) } @{ $self };
48
49 3 return \@tablesArray;
50 }
51  
52  
53 1 1;
54  
55 __END__
56  
57 =pod
58  
59 =encoding UTF-8
60  
61 =head1 NAME
62  
63 JsonSQL::Param::Tables - JsonSQL::Param::Tables object. Stores an array of JsonSQL::Param::Table objects to use for constructing JsonSQL::Query objects.
64  
65 =head1 VERSION
66  
67 version 0.4
68  
69 =head1 SYNOPSIS
70  
71 This module constructs a Perl object container of L<JsonSQL::Param::Table> objects.
72  
73 =head1 DESCRIPTION
74  
75 =head3 Object properties:
76  
77 =over
78  
79 =item Array of L<JsonSQL::Param::Table> objects.
80  
81 =back
82  
83 =head3 Generated parameters:
84  
85 =over
86  
87 =item $tablesArray => \@arrayref
88  
89 =back
90  
91 =head1 METHODS
92  
93 =head2 Constructor new($tablesarrayref, $queryObj)
94  
95 Instantiates and returns a new JsonSQL::Param::Tables object, which is an array of L<JsonSQL::Param::Table> objects.
96  
97 $tablesarrayref => An arrayref of table hashes used to construct the object.
98 $queryObj => A reference to the JsonSQL::Query object that will own this object.
99  
100 Returns a JsonSQL::Error object on failure.
101  
102 =head2 ObjectMethod get_tables -> \@tablesArray
103  
104 Generates parameters represented by the object for the SQL statement. Returns:
105  
106 $tablesArray => Arrayref of table identifiers to use for the query. Constructed from child L<JsonSQL::Param::Table> objects.
107  
108 =head1 AUTHOR
109  
110 Chris Hoefler <bhoefler@draper.com>
111  
112 =head1 COPYRIGHT AND LICENSE
113  
114 This software is copyright (c) 2017 by Chris Hoefler.
115  
116 This is free software; you can redistribute it and/or modify it under
117 the same terms as the Perl 5 programming language system itself.
118  
119 =cut
« JsonSQL/Param/Joins.pm ↑ Summary JsonSQL/Param/Conditions/LogicCondition.pm »