« lib/Reaction/InterfaceModel/Search/UpdateSpec.pm
↑ Summary
lib/Reaction/UI/ViewPort/Role/FieldArgs.pm »
| 1 | package Reaction::UI::ViewPort::Role::Actions; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 5 | ▶ | use Reaction::Role; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 5 | ▶ | use Reaction::UI::ViewPort::URI; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | |||||||||||||||
| 6 | 5 | ▶ | use namespace::clean -except => [ qw(meta) ]; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | |||||||||||||||
| 8 | 5 | has actions => ( | |||||||||||||
| 9 | is => 'ro', | ||||||||||||||
| 10 | isa => 'ArrayRef', | ||||||||||||||
| 11 | lazy_build => 1 | ||||||||||||||
| 12 | ); | ||||||||||||||
| 13 | |||||||||||||||
| 14 | 5 | has action_order => ( | |||||||||||||
| 15 | is => 'ro', | ||||||||||||||
| 16 | isa => 'ArrayRef' | ||||||||||||||
| 17 | ); | ||||||||||||||
| 18 | |||||||||||||||
| 19 | 5 | has action_filter => ( | |||||||||||||
| 20 | isa => 'CodeRef', is => 'ro', | ||||||||||||||
| 21 | ); | ||||||||||||||
| 22 | |||||||||||||||
| 23 | has action_prototypes => ( | ||||||||||||||
| 24 | is => 'ro', | ||||||||||||||
| 25 | isa => 'HashRef', | ||||||||||||||
| 26 | required => 1, | ||||||||||||||
| 27 | 3 | ▶ | default => sub{ {} } | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 28 | 5 | ); | |||||||||||||
| 29 | |||||||||||||||
| 30 | 5 | has computed_action_order => ( | |||||||||||||
| 31 | is => 'ro', | ||||||||||||||
| 32 | isa => 'ArrayRef', | ||||||||||||||
| 33 | lazy_build => 1 | ||||||||||||||
| 34 | ); | ||||||||||||||
| 35 | |||||||||||||||
| 36 | 0 | ▶ | sub _filter_action_list { | ||||||||||||
|
Subroutine
_filter_action_list: not called CC=2 SCAR=17.9
| |||||||||||||||
| 37 | 0 | my $self = shift; | |||||||||||||
| 38 | 0 | my $actions = [keys %{$self->action_prototypes}]; | |||||||||||||
| 39 | 0 | ▶ | return $self->has_action_filter ? | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 40 | $self->action_filter->($actions, $self->model) | ||||||||||||||
| 41 | : $actions; | ||||||||||||||
| 42 | } | ||||||||||||||
| 43 | |||||||||||||||
| 44 | 0 | ▶ | sub _build_computed_action_order { | ||||||||||||
|
Subroutine
_build_computed_action_order: not called CC=2 SCAR=17.9
| |||||||||||||||
| 45 | 0 | my $self = shift; | |||||||||||||
| 46 | 0 | ▶ | my $ordered = $self->sort_by_spec( | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 47 | ($self->has_action_order ? $self->action_order : []), | ||||||||||||||
| 48 | $self->_filter_action_list | ||||||||||||||
| 49 | ); | ||||||||||||||
| 50 | 0 | return $ordered; | |||||||||||||
| 51 | } | ||||||||||||||
| 52 | |||||||||||||||
| 53 | 0 | ▶ | sub _build_actions { | ||||||||||||
|
Subroutine
_build_actions: not called CC=7 SCAR=40.3
| |||||||||||||||
| 54 | 0 | my ($self) = @_; | |||||||||||||
| 55 | 0 | my (@act, $i); | |||||||||||||
| 56 | 0 | my $ctx = $self->ctx; | |||||||||||||
| 57 | 0 | my $loc = $self->location; | |||||||||||||
| 58 | 0 | my $target = $self->model; | |||||||||||||
| 59 | |||||||||||||||
| 60 | 0 | foreach my $proto_name ( @{ $self->computed_action_order } ) { | |||||||||||||
| 61 | 0 | my $proto = $self->action_prototypes->{$proto_name}; | |||||||||||||
| 62 | 0 | ▶ | my $uri = $proto->{uri} or confess('uri is required in prototype action'); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 63 | 0 | ▶ | my $label = exists $proto->{label} ? $proto->{label} : $proto_name; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 64 | 0 | ▶ | my $layout = exists $proto->{layout} ? $proto->{layout} : 'uri'; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 65 | |||||||||||||||
| 66 | 0 | ▶ | my $action = Reaction::UI::ViewPort::URI->new( | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 67 | location => join ('-', $loc, 'action', $i++), | ||||||||||||||
| 68 | uri => ( ref($uri) eq 'CODE' ? $uri->($target, $ctx) : $uri ), | ||||||||||||||
| 69 | display => ( ref($label) eq 'CODE' ? $label->($target, $ctx) : $label ), | ||||||||||||||
| 70 | layout => $layout, | ||||||||||||||
| 71 | ); | ||||||||||||||
| 72 | 0 | push(@act, $action); | |||||||||||||
| 73 | } | ||||||||||||||
| 74 | 0 | return \@act; | |||||||||||||
| 75 | } | ||||||||||||||
| 76 | |||||||||||||||
| 77 | 5 | 1; | |||||||||||||
| 78 | |||||||||||||||
| 79 | __END__; | ||||||||||||||