| 1 | package Articulate::Role::Flow; | ||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 3 | ▶ | use Moo::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | =head1 NAME | ||||||||||
| 7 | |||||||||||
| 8 | Articulate::Role::Flow - methods | ||||||||||
| 9 | |||||||||||
| 10 | =head1 DESCRIPTION | ||||||||||
| 11 | |||||||||||
| 12 | This is a helper class for flow roles. All consumers of this role must have a C<process_method> method which can be called as follows: | ||||||||||
| 13 | |||||||||||
| 14 | $self->process_method( $methodname, $item, $request ); | ||||||||||
| 15 | |||||||||||
| 16 | This role provides a method C<_delegate> which can be used to delegate to other providers. It is called as: | ||||||||||
| 17 | |||||||||||
| 18 | $self->_delegate( $method, $providers, $args ) | ||||||||||
| 19 | |||||||||||
| 20 | where C<$providers> and C<$args> are arrayrefs. | ||||||||||
| 21 | |||||||||||
| 22 | =cut | ||||||||||
| 23 | |||||||||||
| 24 | =head1 METHODS | ||||||||||
| 25 | |||||||||||
| 26 | =cut | ||||||||||
| 27 | |||||||||||
| 28 | =head3 enrich | ||||||||||
| 29 | |||||||||||
| 30 | $self->enrich($item); | ||||||||||
| 31 | |||||||||||
| 32 | Does | ||||||||||
| 33 | |||||||||||
| 34 | $self->process_method( enrich => $item ); | ||||||||||
| 35 | |||||||||||
| 36 | =cut | ||||||||||
| 37 | |||||||||||
| 38 | sub enrich { | ||||||||||
| 39 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
enrich: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 40 | 0 | $self->process_method( enrich => @_ ); | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | =head3 augment | ||||||||||
| 44 | |||||||||||
| 45 | $self->augment($item); | ||||||||||
| 46 | |||||||||||
| 47 | Does | ||||||||||
| 48 | |||||||||||
| 49 | $self->process_method( augment => $item ); | ||||||||||
| 50 | |||||||||||
| 51 | =cut | ||||||||||
| 52 | |||||||||||
| 53 | sub augment { | ||||||||||
| 54 | 12 | ▶ | my $self = shift; | ||||||||
|
Subroutine
augment: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 55 | 12 | $self->process_method( augment => @_ ); | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | sub _delegate { | ||||||||||
| 59 | 6 | ▶ | my ( $self, $method, $providers, $args ) = @_; | ||||||||
|
Subroutine
_delegate: called CC=3 SCAR=11.1
| |||||||||||
| 60 | 6 | foreach my $provider (@$providers) { | |||||||||
| 61 | 6 | my $result = $provider->$method(@$args); | |||||||||
| 62 | 6 | ▶ | return $result unless defined $result; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | } | ||||||||||
| 64 | 6 | return $args->[0]; | |||||||||
| 65 | } | ||||||||||
| 66 | |||||||||||
| 67 | 3 | 1; | |||||||||