JsonSQL/Param/Joins.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/Conditions/TestCondition.pm ↑ Summary JsonSQL/Param/Tables.pm »
1 # ABSTRACT: JsonSQL::Param::Joins object. Stores an array of JsonSQL::Param::Join 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::Joins;
10  
11 1 our $VERSION = '0.4'; # VERSION
12  
13 1 ▶use JsonSQL::Param::Join;
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 1 ▶ my ($class, $joinsarrayref, $queryObj) = @_;
Subroutine new: called CC=4 SCAR=14.8
Pod documented
20
21 1 my $self = [];
22
23 1 my @join_errors;
24 1 for my $joinhashref ( @{ $joinsarrayref } ) {
25 1 my $joinObj = JsonSQL::Param::Join->new($joinhashref, $queryObj);
26 1 ▶ if ( eval { $joinObj->is_error } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { $joinObj->is_error } }) { } 0 1 1
27 0 push(@join_errors, $joinObj->{message});
28 } else {
29 1 push (@{ $self }, $joinObj);
30 }
31 }
32
33 1 ▶ if ( @join_errors ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@join_errors) { } 0 1 1
34 0 my $err = "Could not parse all join objects: \n\t";
35 0 $err .= join("\n\t", @join_errors);
36 0 return JsonSQL::Error->new("invalid_joins", $err);
37 } else {
38 1 bless $self, $class;
39 1 return $self;
40 }
41 }
42  
43  
44 sub get_joins {
45 1 ▶ my ( $self, $queryObj ) = @_;
Subroutine get_joins: called CC=1 SCAR=0.0
Pod documented
46
47 1 my @joinsArray = map { $_->get_join($queryObj) } @{ $self };
48
49 1 return \@joinsArray;
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::Joins - JsonSQL::Param::Joins object. Stores an array of JsonSQL::Param::Join 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::Join> objects.
72  
73 =head1 DESCRIPTION
74  
75 =head3 Object properties:
76  
77 =over
78  
79 =item Array of L<JsonSQL::Param::Join> objects.
80  
81 =back
82  
83 =head3 Generated parameters:
84  
85 =over
86  
87 =item $joinsArray => \@arrayref
88  
89 =back
90  
91 =head1 METHODS
92  
93 =head2 Constructor new($joinsarrayref, $queryObj)
94  
95 Instantiates and returns a new JsonSQL::Param::Joins object, which is an array of L<JsonSQL::Param::Join> objects.
96  
97 $joinsarrayref => An arrayref of join 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_joins -> \@joinsArray
103  
104 Generates parameters represented by the object for the SQL statement. Returns:
105  
106 $joinsArray => Arrayref of joins to use for the query. Constructed from child L<JsonSQL::Param::Join> 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/Conditions/TestCondition.pm ↑ Summary JsonSQL/Param/Tables.pm »