| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Ark::Model::Adaptor; | 
| 2 | 1 |  |  | 1 |  | 476 | use strict; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 29 |  | 
| 3 | 1 |  |  | 1 |  | 5 | use warnings; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 26 |  | 
| 4 | 1 |  |  | 1 |  | 10 | use Ark 'Model'; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 7 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | has class => ( | 
| 7 |  |  |  |  |  |  | is       => 'rw', | 
| 8 |  |  |  |  |  |  | isa      => 'Str', | 
| 9 |  |  |  |  |  |  | required => 1, | 
| 10 |  |  |  |  |  |  | ); | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | has constructor => ( | 
| 13 |  |  |  |  |  |  | is      => 'rw', | 
| 14 |  |  |  |  |  |  | isa     => 'Str', | 
| 15 |  |  |  |  |  |  | default => 'new', | 
| 16 |  |  |  |  |  |  | ); | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | has args => ( | 
| 19 |  |  |  |  |  |  | is  => 'rw', | 
| 20 |  |  |  |  |  |  | isa => 'Ref', | 
| 21 |  |  |  |  |  |  | ); | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | has deref => ( | 
| 24 |  |  |  |  |  |  | is      => 'rw', | 
| 25 |  |  |  |  |  |  | isa     => 'Bool', | 
| 26 |  |  |  |  |  |  | default => 0, | 
| 27 |  |  |  |  |  |  | ); | 
| 28 |  |  |  |  |  |  |  | 
| 29 | 1 |  |  | 1 |  | 9 | no Ark; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 5 |  | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | sub ARK_DELEGATE { | 
| 32 | 3 |  |  | 3 | 0 | 9 | my ($self, $c) = @_; | 
| 33 |  |  |  |  |  |  |  | 
| 34 | 3 |  |  |  |  | 13 | my $class       = $self->class; | 
| 35 | 3 |  |  |  |  | 10 | my $constructor = $self->constructor; | 
| 36 |  |  |  |  |  |  |  | 
| 37 | 3 |  |  |  |  | 17 | $self->ensure_class_loaded($class); | 
| 38 |  |  |  |  |  |  |  | 
| 39 | 3 |  |  |  |  | 9 | my $instance; | 
| 40 | 3 | 50 | 33 |  |  | 28 | if ($self->deref && $self->args) { | 
|  |  | 100 |  |  |  |  |  | 
| 41 | 0 | 0 |  |  |  | 0 | if (ref($self->args) eq 'HASH') { | 
|  |  | 0 |  |  |  |  |  | 
| 42 | 0 |  |  |  |  | 0 | $instance = $class->$constructor(%{ $self->args }); | 
|  | 0 |  |  |  |  | 0 |  | 
| 43 |  |  |  |  |  |  | } | 
| 44 |  |  |  |  |  |  | elsif (ref($self->args) eq 'ARRAY') { | 
| 45 | 0 |  |  |  |  | 0 | $instance = $class->$constructor(@{ $self->args }); | 
|  | 0 |  |  |  |  | 0 |  | 
| 46 |  |  |  |  |  |  | } | 
| 47 |  |  |  |  |  |  | else { | 
| 48 | 0 |  |  |  |  | 0 | die "Couldn't dereference: " . ref($self->args); | 
| 49 |  |  |  |  |  |  | } | 
| 50 |  |  |  |  |  |  | } | 
| 51 |  |  |  |  |  |  | elsif ($self->args) { | 
| 52 | 1 |  |  |  |  | 11 | $instance = $class->$constructor($self->args); | 
| 53 |  |  |  |  |  |  | } | 
| 54 |  |  |  |  |  |  | else { | 
| 55 | 2 |  |  |  |  | 14 | $instance = $class->$constructor; | 
| 56 |  |  |  |  |  |  | } | 
| 57 |  |  |  |  |  |  |  | 
| 58 | 3 |  |  |  |  | 94 | $instance; | 
| 59 |  |  |  |  |  |  | } | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | __PACKAGE__->meta->make_immutable; | 
| 62 |  |  |  |  |  |  |  |