| 1 | package SyForm::Values; | ||||||||||
| 2 | 6 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 6 | $SyForm::Values::AUTHORITY = 'cpan:GETTY'; | |||||||||
| 4 | } | ||||||||||
| 5 | # ABSTRACT: Values given of the fields through the process args | ||||||||||
| 6 | 6 | $SyForm::Values::VERSION = '0.103'; | |||||||||
| 7 | 6 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 6 | with qw( | |||||||||
| 10 | MooX::Traits | ||||||||||
| 11 | SyForm::ValuesRole::Verify | ||||||||||
| 12 | ); | ||||||||||
| 13 | |||||||||||
| 14 | 6 | has syform => ( | |||||||||
| 15 | is => 'ro', | ||||||||||
| 16 | required => 1, | ||||||||||
| 17 | handles => [qw( | ||||||||||
| 18 | field | ||||||||||
| 19 | field_names | ||||||||||
| 20 | )], | ||||||||||
| 21 | ); | ||||||||||
| 22 | |||||||||||
| 23 | 6 | has values => ( | |||||||||
| 24 | is => 'ro', | ||||||||||
| 25 | required => 1, | ||||||||||
| 26 | ); | ||||||||||
| 27 | 0 | ▶ | sub as_hashref { $_[0]->values } | ||||||||
|
Subroutine
as_hashref: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 28 | |||||||||||
| 29 | 6 | has results => ( | |||||||||
| 30 | is => 'lazy', | ||||||||||
| 31 | ); | ||||||||||
| 32 | |||||||||||
| 33 | 11 | ▶ | sub _build_results { | ||||||||
|
Subroutine
_build_results: called CC=4 SCAR=13.9
| |||||||||||
| 34 | 11 | my ( $self ) = @_; | |||||||||
| 35 | 11 | my $results; | |||||||||
| 36 | 11 | eval { | |||||||||
| 37 | 11 | my %results_args; | |||||||||
| 38 | 11 | for my $field ($self->syform->fields->Values) { | |||||||||
| 39 | 38 | my %field_results_args = $field->results_args_by_values($self); | |||||||||
| 40 | 38 | $results_args{$_} = $field_results_args{$_} for keys %field_results_args; | |||||||||
| 41 | } | ||||||||||
| 42 | 11 | $results = $self->create_results( %results_args ); | |||||||||
| 43 | }; | ||||||||||
| 44 | 11 | ▶ | SyForm->throw( UnknownErrorOnValuesBuildResults => $self, $@ ) if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | 11 | return $results; | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 11 | ▶ | sub create_results { | ||||||||
|
Subroutine
create_results: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 49 | 11 | my ( $self, %args ) = @_; | |||||||||
| 50 | 11 | my %results; | |||||||||
| 51 | 11 | for my $field ($self->syform->fields->Values) { | |||||||||
| 52 | 38 | my $name = $field->name; | |||||||||
| 53 | 38 | ▶ | $results{$name} = delete $args{$name} if exists $args{$name}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | } | ||||||||||
| 55 | 11 | return $self->syform->loaded_results_class->new({ | |||||||||
| 56 | values => $self, | ||||||||||
| 57 | results => { %results }, | ||||||||||
| 58 | %args | ||||||||||
| 59 | }); | ||||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | 38 | ▶ | sub get_value { | ||||||||
|
Subroutine
get_value: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 63 | 38 | my ( $self, $name ) = @_; | |||||||||
| 64 | 38 | return $self->values->{$name}; | |||||||||
| 65 | } | ||||||||||
| 66 | |||||||||||
| 67 | 66 | ▶ | sub has_value { | ||||||||
|
Subroutine
has_value: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 68 | 66 | my ( $self, $name ) = @_; | |||||||||
| 69 | 66 | ▶ | return exists($self->values->{$name}) ? 1 : 0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 70 | } | ||||||||||
| 71 | |||||||||||
| 72 | 6 | 1; | |||||||||
| 73 | |||||||||||
| 74 | __END__ | ||||||||||