| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Ado::Model;    #The schema/base class | 
| 2 | 24 |  |  | 24 |  | 1044313 | use 5.010001; | 
|  | 24 |  |  |  |  | 86 |  | 
| 3 | 24 |  |  | 24 |  | 149 | use strict; | 
|  | 24 |  |  |  |  | 58 |  | 
|  | 24 |  |  |  |  | 649 |  | 
| 4 | 24 |  |  | 24 |  | 127 | use warnings; | 
|  | 24 |  |  |  |  | 62 |  | 
|  | 24 |  |  |  |  | 861 |  | 
| 5 | 24 |  |  | 24 |  | 131 | use utf8; | 
|  | 24 |  |  |  |  | 33 |  | 
|  | 24 |  |  |  |  | 192 |  | 
| 6 | 24 |  |  | 24 |  | 10798 | use parent qw(DBIx::Simple::Class); | 
|  | 24 |  |  |  |  | 6469 |  | 
|  | 24 |  |  |  |  | 180 |  | 
| 7 | 24 |  |  | 24 |  | 57279 | use Carp; | 
|  | 24 |  |  |  |  | 47 |  | 
|  | 24 |  |  |  |  | 1922 |  | 
| 8 | 24 |  |  | 24 |  | 14194 | use DBIx::Simple::Class::Schema; | 
|  | 24 |  |  |  |  | 61814 |  | 
|  | 24 |  |  |  |  | 8385 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | our $VERSION = '0.01'; | 
| 11 | 0 |  |  | 0 | 1 | 0 | sub is_base_class { return 1 } | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | sub dbix { | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | # Singleton DBIx::Simple instance | 
| 16 | 437 |  |  | 437 | 1 | 96343 | state $DBIx; | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | # uncoverable statement | 
| 19 | 437 |  | 33 |  |  | 3108 | return ($_[1] ? ($DBIx = $_[1]) : $DBIx) | 
| 20 |  |  |  |  |  |  | || Carp::croak('DBIx::Simple is not instantiated. Please first do ' | 
| 21 |  |  |  |  |  |  | . $_[0] | 
| 22 |  |  |  |  |  |  | . '->dbix(DBIx::Simple->connect($DSN,$u,$p,{...})'); | 
| 23 |  |  |  |  |  |  | } | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | #The methods below are not generated but written additionally | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | sub select_range { | 
| 29 | 4 |  |  | 4 | 1 | 7 | my $class = shift; | 
| 30 | 4 |  |  |  |  | 13 | state $dbix = $class->dbix; | 
| 31 | 4 |  |  |  |  | 27 | my $SQL = $class->SQL('SELECT') . $class->SQL_LIMIT(@_); | 
| 32 | 4 |  |  |  |  | 115 | return $dbix->query($SQL)->objects($class); | 
| 33 |  |  |  |  |  |  | } | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | # Generates classes from tables on the fly and returns the classname. | 
| 36 |  |  |  |  |  |  | sub table_to_class { | 
| 37 | 2 |  |  | 2 | 1 | 30 | my ($class, $args) = shift->_get_obj_args(@_); | 
| 38 | 2 |  |  |  |  | 24 | state $tables = {}; | 
| 39 | 2 |  |  |  |  | 8 | my $table = $args->{table}; | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | # already generated? | 
| 42 | 2 | 50 |  |  |  | 10 | return $tables->{$table} if (exists $tables->{$table}); | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | # uncoverable branch false | 
| 45 | 2 |  | 33 |  |  | 7 | $args->{namespace} //= $class; | 
| 46 | 2 |  |  |  |  | 10 | my $class_name = $args->{namespace} . '::' . Mojo::Util::camelize($table); | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | # loaded from file? | 
| 49 |  |  |  |  |  |  | return $tables->{$table} = $class_name | 
| 50 | 2 | 50 |  |  |  | 33 | if $INC{Mojo::Util::class_to_path($class_name)}; | 
| 51 | 2 |  | 50 |  |  | 39 | state $connected = DBIx::Simple::Class::Schema->dbix($class->dbix) && 1; | 
| 52 |  |  |  |  |  |  | my $perl_code = DBIx::Simple::Class::Schema->load_schema( | 
| 53 |  |  |  |  |  |  | namespace => $args->{namespace}, | 
| 54 |  |  |  |  |  |  | table     => $table, | 
| 55 | 2 |  | 50 |  |  | 50 | type      => $args->{type} || "'TABLE','VIEW'", | 
| 56 |  |  |  |  |  |  | ); | 
| 57 | 2 | 50 |  | 34 |  | 14666 | Carp::croak($@) unless (eval "{$perl_code}");    ## no critic (ProhibitStringyEval) | 
|  | 34 |  |  | 10 |  | 1486 |  | 
|  | 10 |  |  | 12 |  | 412 |  | 
|  | 12 |  |  | 9 |  | 20472 |  | 
|  | 9 |  |  | 13 |  | 157 |  | 
|  | 13 |  |  | 2 |  | 379 |  | 
|  | 4 |  |  |  |  | 87 |  | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 77 |  | 
|  | 2 |  |  |  |  | 8 |  | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 11 |  | 
|  | 2 |  |  |  |  | 94 |  | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 16 |  | 
| 58 |  |  |  |  |  |  |  | 
| 59 | 2 |  |  |  |  | 7 | $tables->{$table} = $class_name; | 
| 60 | 2 |  |  |  |  | 9 | return $tables->{$table}; | 
| 61 |  |  |  |  |  |  | } | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | 1; | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | __END__ |