| 1 | package Gapp::Form::Stash; | ||
| 2 | { | ||
| 3 | 1 | $Gapp::Form::Stash::VERSION = '0.60'; | |
| 4 | } | ||
| 5 | |||
| 6 | 1 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 1 | ▶ | use MooseX::StrictConstructor; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 1 | ▶ | use MooseX::SemiAffordanceAccessor; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 1 | ▶ | use Try::Tiny; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | has 'storage' => ( | ||
| 13 | is => 'bare', | ||
| 14 | isa => 'HashRef', | ||
| 15 | 1 | ▶ | default => sub { { } }, |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 16 | 1 | traits => [qw( Hash )], | |
| 17 | clearer => 'clear', | ||
| 18 | handles => { | ||
| 19 | store => 'set', | ||
| 20 | fetch => 'get', | ||
| 21 | contains => 'exists', | ||
| 22 | delete => 'delete', | ||
| 23 | elements => 'keys', | ||
| 24 | }, | ||
| 25 | lazy => 1, | ||
| 26 | ); | ||
| 27 | |||
| 28 | # if the stash has been modified via the form | ||
| 29 | 1 | has 'modified' => ( | |
| 30 | is => 'rw', | ||
| 31 | isa => 'Bool', | ||
| 32 | default => 0, | ||
| 33 | ); | ||
| 34 | |||
| 35 | |||
| 36 | |||
| 37 | # if the context has updated the stash | ||
| 38 | 1 | ▶ | after 'store' => sub { $_[0]->set_modified(1) }; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 39 | 0 | ▶ | after 'delete' => sub { $_[0]->set_modified(1) }; |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 40 | |||
| 41 | |||
| 42 | 0 | ▶ | sub update { |
|
Subroutine
update: not called CC=2 SCAR=17.9
Pod
undocumented
| |||
| 43 | 0 | my ( $self, $cx ) = @_; | |
| 44 | |||
| 45 | 0 | for my $field ( $self->elements ) { | |
| 46 | |||
| 47 | 0 | ▶ | try { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 48 | 0 | my $value = $cx->lookup( $field ); | |
| 49 | 0 | $self->store( $field, $value ); | |
| 50 | } | ||
| 51 | |||
| 52 | |||
| 53 | 0 | } | |
| 54 | |||
| 55 | 0 | $self->set_modified( 0 ); | |
| 56 | } | ||
| 57 | |||
| 58 | 0 | ▶ | sub update_from_context { |
|
Subroutine
update_from_context: not called CC=1 SCAR=1.2
Pod
undocumented
| |||
| 59 | 0 | my $self = shift; | |
| 60 | 1 | ▶ | use Carp qw( cluck ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 61 | 0 | cluck '$stash->update_from_context( $cx ) deprecated, use $stash->update( $cx ) instead'; | |
| 62 | 0 | $self->update( @_ ); | |
| 63 | } | ||
| 64 | |||
| 65 | |||
| 66 | |||
| 67 | |||
| 68 | 1 | 1; | |
| 69 | |||
| 70 | |||
| 71 | __END__ | ||