| 1 | package SyForm::Role::Process; | ||||||||||||||||||||||||||||||||||||||
| 2 | 7 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 3 | 7 | $SyForm::Role::Process::AUTHORITY = 'cpan:GETTY'; | |||||||||||||||||||||||||||||||||||||
| 4 | } | ||||||||||||||||||||||||||||||||||||||
| 5 | # ABSTRACT: SyForm role for processing | ||||||||||||||||||||||||||||||||||||||
| 6 | 7 | $SyForm::Role::Process::VERSION = '0.103'; | |||||||||||||||||||||||||||||||||||||
| 7 | 7 | ▶ | use Moo::Role; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 8 | 7 | ▶ | use Module::Runtime qw( use_module ); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||
| 10 | 7 | with qw( | |||||||||||||||||||||||||||||||||||||
| 11 | SyForm::Role::Verify | ||||||||||||||||||||||||||||||||||||||
| 12 | SyForm::Role::HTML | ||||||||||||||||||||||||||||||||||||||
| 13 | SyForm::Role::Bootstrap | ||||||||||||||||||||||||||||||||||||||
| 14 | ); | ||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||
| 16 | ########## | ||||||||||||||||||||||||||||||||||||||
| 17 | # | ||||||||||||||||||||||||||||||||||||||
| 18 | # Process | ||||||||||||||||||||||||||||||||||||||
| 19 | # | ||||||||||||||||||||||||||||||||||||||
| 20 | ########## | ||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||
| 22 | 8 | ▶ | sub process { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
process: called CC=4 SCAR=15.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 23 | 8 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||
| 24 | 8 | my $view; | |||||||||||||||||||||||||||||||||||||
| 25 | 8 | eval { $view = $self->process_view(@args) }; | |||||||||||||||||||||||||||||||||||||
| 26 | 8 | ▶ | SyForm->throw( UnknownErrorOnProcess => $self,[@args], $@ || '$view is undefined' ) if $@ || !defined $view; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition20%1/5
$@ or not defined $view
$@ || '$view is undefined'
MC/DC0%0/2
$@ or not defined $view
$@
not defined $view
MC/DC0%0/1
$@ || '$view is undefined'
$@
Truth table33%1/3
A or not(B)
A= $@B= not defined $view
Truth table0%0/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||
| 27 | 8 | return $view; | |||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||
| 30 | ################# | ||||||||||||||||||||||||||||||||||||||
| 31 | # | ||||||||||||||||||||||||||||||||||||||
| 32 | # Process Values | ||||||||||||||||||||||||||||||||||||||
| 33 | # | ||||||||||||||||||||||||||||||||||||||
| 34 | ################# | ||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||
| 36 | 7 | has values_class => ( | |||||||||||||||||||||||||||||||||||||
| 37 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||
| 40 | 7 | ▶ | sub _build_values_class { return 'SyForm::Values' } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_values_class: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||
| 42 | 7 | has loaded_values_class => ( | |||||||||||||||||||||||||||||||||||||
| 43 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||
| 44 | ); | ||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||
| 46 | 7 | ▶ | sub _build_loaded_values_class { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_loaded_values_class: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 47 | 7 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||
| 48 | 7 | return use_module($self->values_class); | |||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||
| 51 | 11 | ▶ | sub process_values { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
process_values: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 52 | 11 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||
| 53 | 11 | return $self->create_values_by_args(@args); | |||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||
| 56 | 11 | ▶ | sub create_values_by_args { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
create_values_by_args: called CC=7 SCAR=22.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 57 | 11 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||
| 58 | 11 | my %args_hash; | |||||||||||||||||||||||||||||||||||||
| 59 | 11 | my $args_count = scalar @args; | |||||||||||||||||||||||||||||||||||||
| 60 | 11 | ▶ | if ($args_count == 1) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if (ref $args[0] eq 'HASH') { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 62 | 0 | %args_hash = %{$args[0]}; | |||||||||||||||||||||||||||||||||||||
| 63 | } else { | ||||||||||||||||||||||||||||||||||||||
| 64 | 0 | SyForm->throw( UnknownArgOnCreateValuesByArgs => $self,$args[0] ); | |||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||
| 66 | } elsif ($args_count % 2 == 0) { | ||||||||||||||||||||||||||||||||||||||
| 67 | 11 | %args_hash = ( @args ); | |||||||||||||||||||||||||||||||||||||
| 68 | } else { | ||||||||||||||||||||||||||||||||||||||
| 69 | 0 | SyForm->throw( OddNumberOfArgsOnCreateValuesByArgs => $self,[@args] ); | |||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||
| 71 | 11 | my $values; | |||||||||||||||||||||||||||||||||||||
| 72 | 11 | eval { | |||||||||||||||||||||||||||||||||||||
| 73 | 11 | my %values_args; | |||||||||||||||||||||||||||||||||||||
| 74 | 11 | for my $field ($self->fields->Values) { | |||||||||||||||||||||||||||||||||||||
| 75 | 38 | my %field_values_args = $field->values_args_by_process_args(%args_hash); | |||||||||||||||||||||||||||||||||||||
| 76 | 38 | $values_args{$_} = $field_values_args{$_} for keys %field_values_args; | |||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||
| 78 | 11 | $values = $self->create_values(%values_args); | |||||||||||||||||||||||||||||||||||||
| 79 | }; | ||||||||||||||||||||||||||||||||||||||
| 80 | 11 | ▶ | SyForm->throw( UnknownErrorOnCreateValuesByArgs => $self,[@args], $@ ) if $@; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 81 | 11 | return $values; | |||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||
| 84 | 11 | ▶ | sub create_values { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
create_values: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 85 | 11 | my ( $self, %args ) = @_; | |||||||||||||||||||||||||||||||||||||
| 86 | 11 | my %values; | |||||||||||||||||||||||||||||||||||||
| 87 | 11 | for my $field ($self->fields->Values) { | |||||||||||||||||||||||||||||||||||||
| 88 | 38 | my $name = $field->name; | |||||||||||||||||||||||||||||||||||||
| 89 | 38 | ▶ | $values{$name} = delete $args{$name} if exists $args{$name}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||
| 91 | 11 | return $self->loaded_values_class->new({ | |||||||||||||||||||||||||||||||||||||
| 92 | syform => $self, | ||||||||||||||||||||||||||||||||||||||
| 93 | values => { %values }, | ||||||||||||||||||||||||||||||||||||||
| 94 | %args, | ||||||||||||||||||||||||||||||||||||||
| 95 | }); | ||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||
| 98 | ########## | ||||||||||||||||||||||||||||||||||||||
| 99 | # | ||||||||||||||||||||||||||||||||||||||
| 100 | # Results | ||||||||||||||||||||||||||||||||||||||
| 101 | # | ||||||||||||||||||||||||||||||||||||||
| 102 | ########## | ||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||
| 104 | 7 | has results_class => ( | |||||||||||||||||||||||||||||||||||||
| 105 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||
| 106 | ); | ||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||
| 108 | 7 | ▶ | sub _build_results_class { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_results_class: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 109 | 7 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||
| 110 | 7 | return 'SyForm::Results'; | |||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||
| 113 | 7 | has loaded_results_class => ( | |||||||||||||||||||||||||||||||||||||
| 114 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||
| 115 | ); | ||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||
| 117 | 7 | ▶ | sub _build_loaded_results_class { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_loaded_results_class: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 118 | 7 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||
| 119 | 7 | return use_module($self->results_class); | |||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||
| 122 | 11 | ▶ | sub process_results { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
process_results: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 123 | 11 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||
| 124 | 11 | my $values = $self->process_values(@args); | |||||||||||||||||||||||||||||||||||||
| 125 | 11 | return $values->results; | |||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||
| 128 | ####### | ||||||||||||||||||||||||||||||||||||||
| 129 | # | ||||||||||||||||||||||||||||||||||||||
| 130 | # View | ||||||||||||||||||||||||||||||||||||||
| 131 | # | ||||||||||||||||||||||||||||||||||||||
| 132 | ####### | ||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||
| 134 | 7 | has view_class => ( | |||||||||||||||||||||||||||||||||||||
| 135 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||
| 136 | ); | ||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||
| 138 | 6 | ▶ | sub _build_view_class { return 'SyForm::View' } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_view_class: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||
| 140 | 7 | has loaded_view_class => ( | |||||||||||||||||||||||||||||||||||||
| 141 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||
| 142 | ); | ||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||
| 144 | 6 | ▶ | sub _build_loaded_view_class { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_loaded_view_class: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 145 | 6 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||
| 146 | 6 | return use_module($self->view_class); | |||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||
| 149 | 8 | ▶ | sub process_view { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
process_view: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 150 | 8 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||
| 151 | 8 | my $results = $self->process_results(@args); | |||||||||||||||||||||||||||||||||||||
| 152 | 8 | return $results->view; | |||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||
| 155 | 7 | 1; | |||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||
| 157 | __END__ | ||||||||||||||||||||||||||||||||||||||