| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | #!/usr/bin/perl | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 1 |  |  | 1 |  | 5 | use strict; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 29 |  | 
| 4 | 1 |  |  | 1 |  | 5 | use warnings; | 
|  | 1 |  |  |  |  | 31 |  | 
|  | 1 |  |  |  |  | 43 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | package WWW::Shopify::Field::Relation; | 
| 7 | 1 |  |  | 1 |  | 5 | use parent 'WWW::Shopify::Field'; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 6 |  | 
| 8 |  |  |  |  |  |  | sub new { | 
| 9 | 0 |  |  | 0 | 0 |  | my $package = shift; | 
| 10 | 0 |  |  |  |  |  | my $calling_package = caller(0); | 
| 11 | 0 |  |  |  |  |  | return bless { | 
| 12 |  |  |  |  |  |  | arguments => [@_], | 
| 13 |  |  |  |  |  |  | name => undef, | 
| 14 |  |  |  |  |  |  | owner => $calling_package, | 
| 15 |  |  |  |  |  |  | relation => $_[0] | 
| 16 |  |  |  |  |  |  | }, $package; | 
| 17 |  |  |  |  |  |  | } | 
| 18 | 0 |  |  | 0 | 0 |  | sub relation { return $_[0]->{relation}; } | 
| 19 | 0 |  |  | 0 | 0 |  | sub is_relation { return 1; } | 
| 20 | 0 |  |  | 0 | 0 |  | sub is_many { return undef; } | 
| 21 | 0 |  |  | 0 | 0 |  | sub is_one { return undef; } | 
| 22 | 0 |  |  | 0 | 0 |  | sub is_own { return undef; } | 
| 23 | 0 |  |  | 0 | 0 |  | sub is_reference { return undef; } | 
| 24 | 0 |  |  | 0 | 0 |  | sub is_parent { return undef; } | 
| 25 | 0 |  |  | 0 | 0 |  | sub sql_type { return WWW::Shopify::Field::Identifier->sql_type(); } | 
| 26 |  |  |  |  |  |  |  | 
| 27 | 0 |  | 0 | 0 | 0 |  | sub is_db_belongs_to { return ($_[0]->is_reference && $_[0]->is_one) || ($_[0]->is_one && $_[0]->is_own && (!$_[0]->relation->parent || $_[0]->relation->parent ne $_[0]->owner )); } | 
| 28 | 0 |  | 0 | 0 | 0 |  | sub is_db_has_one { return $_[0]->is_one && $_[0]->is_own && $_[0]->relation->parent && $_[0]->relation->parent eq $_[0]->owner} | 
| 29 | 0 |  | 0 | 0 | 0 |  | sub is_db_has_many { return !$_[0]->is_db_belongs_to && !$_[0]->is_db_has_one && $_[0]->is_many && $_[0]->relation->parent && $_[0]->relation->parent eq $_[0]->owner; } | 
| 30 | 0 |  | 0 | 0 | 0 |  | sub is_db_many_many { return !$_[0]->is_db_belongs_to && !$_[0]->is_db_has_one && !$_[0]->is_db_has_many && ($_[0]->is_many || $_[0]->is_own); } | 
| 31 |  |  |  | 0 | 0 |  | sub db_min_count { } | 
| 32 |  |  |  | 0 | 0 |  | sub db_max_count { } | 
| 33 | 1 |  |  | 1 |  | 1300 | use Math::Round qw(round); | 
|  | 1 |  |  |  |  | 9340 |  | 
|  | 1 |  |  |  |  | 131 |  | 
| 34 | 0 |  |  | 0 | 0 |  | sub db_rand_count { return $_[0]->db_min_count + round(rand($_[0]->db_max_count - $_[0]->db_min_count)); } | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | package WWW::Shopify::Field::Relation::Parent; | 
| 37 | 1 |  |  | 1 |  | 8 | use parent 'WWW::Shopify::Field::Relation'; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 9 |  | 
| 38 | 0 |  |  | 0 |  |  | sub is_parent { return 1; } | 
| 39 | 0 |  |  | 0 |  |  | sub is_reference { return 1; } | 
| 40 | 0 |  |  | 0 |  |  | sub is_one { return 1; } | 
| 41 |  |  |  |  |  |  |  | 
| 42 | 0 |  |  | 0 |  |  | sub db_min_count { return 1; } | 
| 43 | 0 |  |  | 0 |  |  | sub db_max_count { return 1; } | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | package WWW::Shopify::Field::Relation::Many; | 
| 46 | 1 |  |  | 1 |  | 138 | use parent 'WWW::Shopify::Field::Relation'; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 5 |  | 
| 47 | 0 |  |  | 0 |  |  | sub is_many { return 1; } | 
| 48 |  |  |  |  |  |  |  | 
| 49 | 0 | 0 |  | 0 |  |  | sub db_min_count { return defined $_[0]->{arguments}->[1] ? $_[0]->{arguments}->[1] : 0; } | 
| 50 | 0 | 0 |  | 0 |  |  | sub db_max_count { return defined $_[0]->{arguments}->[2] ? $_[0]->{arguments}->[2] : 5; } | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | package WWW::Shopify::Field::Relation::ReferenceOne; | 
| 53 | 1 |  |  | 1 |  | 218 | use parent 'WWW::Shopify::Field::Relation'; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 5 |  | 
| 54 | 0 |  |  | 0 |  |  | sub is_one { return 1; } | 
| 55 | 0 |  |  | 0 |  |  | sub is_reference { return 1; } | 
| 56 | 0 |  |  | 0 |  |  | sub data_type { return WWW::Shopify::Field->TYPE_QUANTITATIVE; } | 
| 57 |  |  |  |  |  |  |  | 
| 58 | 0 | 0 |  | 0 |  |  | sub db_min_count { return defined $_[0]->{arguments}->[1] ? $_[0]->{arguments}->[1] : 0; } | 
| 59 | 0 |  |  | 0 |  |  | sub db_max_count { return 1; } | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | package WWW::Shopify::Field::Relation::OwnOne; | 
| 62 | 1 |  |  | 1 |  | 176 | use parent 'WWW::Shopify::Field::Relation'; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 4 |  | 
| 63 | 0 |  |  | 0 |  |  | sub is_one { return 1; } | 
| 64 | 0 |  |  | 0 |  |  | sub is_own { return 1; } | 
| 65 |  |  |  |  |  |  |  | 
| 66 | 0 | 0 |  | 0 |  |  | sub db_min_count { return defined $_[0]->{arguments}->[1] ? $_[0]->{arguments}->[1] : 0; } | 
| 67 | 0 |  |  | 0 |  |  | sub db_max_count { return 1; } | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | 1; |