| 1 | #!/usr/bin/perl | ||
| 2 | |||
| 3 | package Class::Workflow::State::AcceptHooks; | ||
| 4 | 5 | ▶ | use Moose::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | has hooks => ( | ||
| 7 | isa => "ArrayRef", | ||
| 8 | is => "rw", | ||
| 9 | auto_deref => 1, | ||
| 10 | 17 | ▶ | default => sub { [] }, |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 11 | 5 | ); | |
| 12 | |||
| 13 | 0 | ▶ | sub clear_hooks { |
|
Subroutine
clear_hooks: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 14 | 0 | my $self = shift; | |
| 15 | 0 | $self->hooks( [] ); | |
| 16 | } | ||
| 17 | |||
| 18 | 1 | ▶ | sub add_hook { |
|
Subroutine
add_hook: called CC=1 SCAR=0.0
Pod
documented
| |||
| 19 | 1 | my ( $self, $hook ) = @_; | |
| 20 | 1 | $self->add_hooks( $hook ); | |
| 21 | } | ||
| 22 | |||
| 23 | 1 | ▶ | sub add_hooks { |
|
Subroutine
add_hooks: called CC=1 SCAR=0.0
Pod
documented
| |||
| 24 | 1 | my ( $self, @hooks ) = @_; | |
| 25 | 1 | push @{ $self->hooks }, @hooks; | |
| 26 | } | ||
| 27 | |||
| 28 | 11 | ▶ | after accept_instance => sub { |
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||
| 29 | 11 | my ( $self, $instance, @args ) = @_; | |
| 30 | 11 | $_->( $instance, @args ) for $self->hooks; | |
| 31 | 5 | }; | |
| 32 | |||
| 33 | 5 | __PACKAGE__; | |
| 34 | |||
| 35 | __END__ | ||