« lib/Reaction/UI/ViewPort/Field/Mutable/ChooseOne.pm
↑ Summary
lib/Reaction/UI/Controller/Collection/CRUD.pm »
| 1 | package Reaction::InterfaceModel::Action; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use Reaction::Meta::InterfaceModel::Action::Class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use metaclass 'Reaction::Meta::InterfaceModel::Action::Class'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use Reaction::Meta::Attribute; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use Reaction::Class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 5 | ▶ | use namespace::clean -except => [ qw(meta) ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 16 | ▶ | sub _debug { $ENV{REACTION_IM_ACTION_DEBUG} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_debug: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 5 | has error_message => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | metaclass => 'Reaction::Meta::Attribute' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 5 | has target_model => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | metaclass => 'Reaction::Meta::Attribute' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 5 | has ctx => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | isa => 'Catalyst', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | lazy_fail => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | metaclass => 'Reaction::Meta::Attribute', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | weak_ref => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 32 | ▶ | sub parameter_attributes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parameter_attributes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 32 | shift->meta->parameter_attributes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 4 | ▶ | sub parameter_hashref { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parameter_hashref: called CC=7 SCAR=24.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 4 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 4 | my %params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 4 | foreach my $attr ($self->parameter_attributes) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 16 | my $reader = $attr->get_read_method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 16 | my $predicate = $attr->get_predicate_method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | warn "${\$attr->name} has default: ${\$attr->has_default}" if _debug(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 16 | ▶ | next if defined($predicate) && !$self->$predicate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition22%2/9
defined $predicate and not $self->$predicate and $attr->is_lazy_fail || !$attr->has_default
defined $predicate and not $self->$predicate
$attr->is_lazy_fail or not $attr->has_default
MC/DC0%0/4
defined $predicate and not $self->$predicate and $attr->is_lazy_fail || !$attr->has_default
defined $predicate
not $self->$predicate
$attr->is_lazy_fail
not $attr->has_default
Truth table20%1/5
A and not(B) and C or not(D)
A= defined $predicateB= not $self->$predicateC= $attr->is_lazy_failD= not $attr->has_default
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | && ($attr->is_lazy_fail || !$attr->has_default); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 16 | $params{$attr->name} = $self->$reader; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 4 | return \%params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 2 | ▶ | sub can_apply { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
can_apply: called CC=13 SCAR=35.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 2 | foreach my $attr ($self->parameter_attributes) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 8 | my $predicate = $attr->get_predicate_method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 8 | ▶ | if ($self->attribute_is_required($attr)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | confess "No predicate for required attribute ${\$attr->name} for ${self}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | unless $predicate; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 4 | ▶ | if( !$self->$predicate && ($attr->is_lazy_fail || !$attr->has_default) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition16%1/6
not $self->$predicate and $attr->is_lazy_fail || !$attr->has_default
$attr->is_lazy_fail or not $attr->has_default
MC/DC0%0/3
not $self->$predicate and $attr->is_lazy_fail || !$attr->has_default
not $self->$predicate
$attr->is_lazy_fail
not $attr->has_default
Truth table25%1/4
not(A) and B or not(C)
A= not $self->$predicateB= $attr->is_lazy_failC= not $attr->has_default
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | warn "${\$attr->name} is required but hasn't been set" if _debug(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 8 | ▶ | if ($attr->has_valid_values) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 2 | ▶ | unless ($predicate && !($self->$predicate)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$predicate and not $self->$predicate
MC/DC0%0/2
$predicate and not $self->$predicate
$predicate
not $self->$predicate
Truth table33%1/3
A and not(B)
A= $predicateB= not $self->$predicate
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 2 | my $reader = $attr->get_read_method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 2 | ▶ | unless( $attr->check_valid_value($self, $self->$reader) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | warn "\${\$self->$reader} isn't a valid value for ${\$attr->name}" if _debug(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 8 | ▶ | sub error_for { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error_for: called CC=4 SCAR=18.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 8 | my ($self, $attr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 8 | ▶ | confess "No attribute passed to error_for" unless defined($attr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 8 | ▶ | unless (ref($attr)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | my $meta = $self->meta->find_attribute_by_name($attr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | confess "Can't find attribute ${attr} on $self" unless $meta; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | $attr = $meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 8 | return $self->error_for_attribute($attr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 8 | ▶ | sub error_for_attribute { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error_for_attribute: called CC=6 SCAR=18.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 8 | my ($self, $attr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 8 | my $reader = $attr->get_read_method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 8 | my $predicate = $attr->get_predicate_method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 8 | ▶ | if ($self->attribute_is_required($attr)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 4 | ▶ | unless ($self->$predicate) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | return $attr->name." is required"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 8 | ▶ | if ($self->$predicate && $attr->has_valid_values) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->$predicate and $attr->has_valid_values
MC/DC50%1/2
$self->$predicate and $attr->has_valid_values
$self->$predicate
$attr->has_valid_values
Truth table66%2/3
A and B
A= $self->$predicateB= $attr->has_valid_values
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 2 | ▶ | unless ($attr->check_valid_value($self, $self->$reader)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | return "Not a valid value for ".$attr->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 8 | return; # ok | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 25 | ▶ | sub attribute_is_required { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attribute_is_required: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 25 | my ($self, $attr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 25 | return $attr->is_required; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 2 | ▶ | sub sync_all { } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sync_all: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 5 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | Reaction::InterfaceModel::Action | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | =head2 target_model | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | =head2 ctx | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | =head2 parameter_attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | L<Reaction::Meta::Attribute> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | =head1 AUTHORS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | See L<Reaction::Class> for authors. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | See L<Reaction::Class> for the license. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||