| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Geoffrey::Changeset; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 3 |  |  | 3 |  | 20824 | use utf8; | 
|  | 3 |  |  |  |  | 20 |  | 
|  | 3 |  |  |  |  | 17 |  | 
| 4 | 3 |  |  | 3 |  | 115 | use 5.016; | 
|  | 3 |  |  |  |  | 13 |  | 
| 5 | 3 |  |  | 3 |  | 17 | use strict; | 
|  | 3 |  |  |  |  | 17 |  | 
|  | 3 |  |  |  |  | 61 |  | 
| 6 | 3 |  |  | 3 |  | 34 | use warnings; | 
|  | 3 |  |  |  |  | 16 |  | 
|  | 3 |  |  |  |  | 95 |  | 
| 7 | 3 |  |  | 3 |  | 500 | use Geoffrey::Utils; | 
|  | 3 |  |  |  |  | 6 |  | 
|  | 3 |  |  |  |  | 152 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | $Geoffrey::Changeset::VERSION = '0.000204'; | 
| 10 |  |  |  |  |  |  |  | 
| 11 | 3 |  |  | 3 |  | 434 | use parent 'Geoffrey::Role::Core'; | 
|  | 3 |  |  |  |  | 276 |  | 
|  | 3 |  |  |  |  | 19 |  | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | sub action { | 
| 14 | 36 |  |  | 36 | 1 | 98 | my ( $self, $s_action ) = @_; | 
| 15 | 36 |  |  |  |  | 155 | return Geoffrey::Utils::action_obj_from_name( | 
| 16 |  |  |  |  |  |  | $s_action, | 
| 17 |  |  |  |  |  |  | dbh       => $self->dbh, | 
| 18 |  |  |  |  |  |  | converter => $self->converter, | 
| 19 |  |  |  |  |  |  | template  => $self->template, | 
| 20 |  |  |  |  |  |  | ); | 
| 21 |  |  |  |  |  |  | } | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | sub postfix { | 
| 24 | 3 | 50 | 0 | 3 | 1 | 13 | return $_[0]->{postfix} // q~~ if !defined $_[1]; | 
| 25 | 3 |  |  |  |  | 9 | $_[0]->{postfix} = $_[1]; | 
| 26 | 3 |  |  |  |  | 10 | return $_[0]->{postfix}; | 
| 27 |  |  |  |  |  |  | } | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | sub prefix { | 
| 30 | 3 | 50 | 0 | 3 | 1 | 469 | return $_[0]->{prefix} // q~~ if !defined $_[1]; | 
| 31 | 3 |  |  |  |  | 14 | $_[0]->{prefix} = $_[1]; | 
| 32 | 3 |  |  |  |  | 11 | return $_[0]->{prefix}; | 
| 33 |  |  |  |  |  |  | } | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | sub template { | 
| 36 | 37 | 100 | 100 | 37 | 1 | 256 | return $_[0]->{template} // q~~ if !defined $_[1]; | 
| 37 | 1 |  |  |  |  | 4 | $_[0]->{template} = $_[1]; | 
| 38 | 1 |  |  |  |  | 3 | return $_[0]->{template}; | 
| 39 |  |  |  |  |  |  | } | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | sub handle_entry { | 
| 42 | 36 |  |  | 36 | 1 | 209 | my ( $self, $hr_entry ) = @_; | 
| 43 | 36 | 50 |  |  |  | 92 | return unless $hr_entry; | 
| 44 | 36 | 50 |  |  |  | 114 | unless ( $hr_entry->{action} ) { | 
| 45 | 0 |  |  |  |  | 0 | require Geoffrey::Exception::General; | 
| 46 | 0 |  |  |  |  | 0 | Geoffrey::Exception::General::throw_no_params( 'handle_entry', 'action', $hr_entry ); | 
| 47 |  |  |  |  |  |  | } | 
| 48 | 36 |  |  |  |  | 170 | my ( $s_sub, $s_action ) = Geoffrey::Utils::parse_package_sub( delete $hr_entry->{action} ); | 
| 49 | 36 |  |  |  |  | 143 | my $o_action = $self->action($s_action); | 
| 50 | 35 | 100 | 66 |  |  | 371 | if ( !$s_sub || !$o_action->can($s_sub) ) { | 
| 51 | 1 |  |  |  |  | 553 | require Geoffrey::Exception::RequiredValue; | 
| 52 | 1 |  |  |  |  | 5 | Geoffrey::Exception::RequiredValue::throw_action_sub($s_action); | 
| 53 |  |  |  |  |  |  | } | 
| 54 | 34 | 100 |  |  |  | 109 | $o_action->dryrun(1) if delete $hr_entry->{dryrun}; | 
| 55 | 34 |  |  |  |  | 142 | my $result = $o_action->$s_sub($hr_entry); | 
| 56 | 12 |  |  |  |  | 135 | $o_action->dryrun(0); | 
| 57 | 12 |  |  |  |  | 245 | return $result; | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | } | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | sub handle_entries { | 
| 62 | 30 |  |  | 30 | 1 | 1094 | my ( $self, $ar_entries ) = @_; | 
| 63 | 30 | 50 |  |  |  | 80 | return unless $ar_entries; | 
| 64 | 30 |  |  |  |  | 56 | $self->handle_entry($_) for ( @{$ar_entries} ); | 
|  | 30 |  |  |  |  | 124 |  | 
| 65 | 6 |  |  |  |  | 23 | return scalar @{$ar_entries}; | 
|  | 6 |  |  |  |  | 26 |  | 
| 66 |  |  |  |  |  |  | } | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | 1;    # End of Geoffrey::Changeset | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  | __END__ |