| line | stmt | bran | cond | sub | pod | time | code | 
| 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 |  |  | 1 |  | 5 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 24 |  | 
| 6 | 1 |  |  | 1 |  | 4 | use warnings; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 20 |  | 
| 7 | 1 |  |  | 1 |  | 12 | use 5.014; | 
|  | 1 |  |  |  |  | 3 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | package JsonSQL::Param::Tables; | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | our $VERSION = '0.41'; # VERSION | 
| 12 |  |  |  |  |  |  |  | 
| 13 | 1 |  |  | 1 |  | 267 | use JsonSQL::Param::Table; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 21 |  | 
| 14 | 1 |  |  | 1 |  | 5 | use JsonSQL::Error; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 170 |  | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | sub new { | 
| 19 | 4 |  |  | 4 | 1 | 12 | my ( $class, $tablesarrayref, $queryObj ) = @_; | 
| 20 |  |  |  |  |  |  |  | 
| 21 | 4 |  |  |  |  | 8 | my $self = []; | 
| 22 | 4 |  |  |  |  | 7 | my @table_errors; | 
| 23 |  |  |  |  |  |  |  | 
| 24 | 4 |  |  |  |  | 7 | for my $tablehashref ( @{ $tablesarrayref } ) { | 
|  | 4 |  |  |  |  | 9 |  | 
| 25 | 4 |  |  |  |  | 21 | my $tableObj = JsonSQL::Param::Table->new($tablehashref, $queryObj); | 
| 26 | 4 | 50 |  |  |  | 6 | if ( eval { $tableObj->is_error } ) { | 
|  | 4 |  |  |  |  | 43 |  | 
| 27 | 0 |  |  |  |  | 0 | push(@table_errors, "Error creating table $tablehashref->{table}: $tableObj->{message}"); | 
| 28 |  |  |  |  |  |  | } else { | 
| 29 | 4 |  |  |  |  | 92 | push (@{ $self }, $tableObj); | 
|  | 4 |  |  |  |  | 14 |  | 
| 30 |  |  |  |  |  |  | } | 
| 31 |  |  |  |  |  |  | } | 
| 32 |  |  |  |  |  |  |  | 
| 33 | 4 | 50 |  |  |  | 12 | if ( @table_errors ) { | 
| 34 | 0 |  |  |  |  | 0 | my $err = "Could not parse all table objects: \n\t"; | 
| 35 | 0 |  |  |  |  | 0 | $err .= join("\n\t", @table_errors); | 
| 36 | 0 |  |  |  |  | 0 | return JsonSQL::Error->new("invalid_tables", $err); | 
| 37 |  |  |  |  |  |  | } else { | 
| 38 | 4 |  |  |  |  | 8 | bless $self, $class; | 
| 39 | 4 |  |  |  |  | 12 | return $self; | 
| 40 |  |  |  |  |  |  | } | 
| 41 |  |  |  |  |  |  | } | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | sub get_tables { | 
| 45 | 3 |  |  | 3 | 1 | 8 | my ( $self, $queryObj ) = @_; | 
| 46 |  |  |  |  |  |  |  | 
| 47 | 3 |  |  |  |  | 13 | my @tablesArray = map { $_->get_table_param($queryObj) } @{ $self }; | 
|  | 3 |  |  |  |  | 12 |  | 
|  | 3 |  |  |  |  | 9 |  | 
| 48 |  |  |  |  |  |  |  | 
| 49 | 3 |  |  |  |  | 15 | return \@tablesArray; | 
| 50 |  |  |  |  |  |  | } | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | 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.41 | 
| 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 |