| 1 | package Patterns::ChainOfResponsibility::Application; | ||
| 2 | |||
| 3 | 2 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 2 | has handlers => ( | |
| 6 | is => 'ro', | ||
| 7 | isa => 'ArrayRef[Object]', | ||
| 8 | required => 1, | ||
| 9 | ); | ||
| 10 | |||
| 11 | 3 | ▶ | sub process { |
|
Subroutine
process: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 12 | 3 | my ($self, @args) = @_; | |
| 13 | 3 | my ($first, @rest) = @{$self->handlers}; | |
| 14 | 3 | $first | |
| 15 | ->next_handlers(@rest) | ||
| 16 | ->process(@args); | ||
| 17 | } | ||
| 18 | |||
| 19 | =head1 NAME | ||
| 20 | |||
| 21 | Patterns::ChainOfResponsibility::Application - Chain of Responsiblity application | ||
| 22 | |||
| 23 | =head1 SYNOPSIS | ||
| 24 | |||
| 25 | use Patterns::ChainOfResponsibility::Application; | ||
| 26 | use MyApp::HanderOne; | ||
| 27 | use MyApp::HanderTwo; | ||
| 28 | |||
| 29 | my %opts = ( | ||
| 30 | handlers => [ | ||
| 31 | MyApp::HandlerOne->new(), | ||
| 32 | MyApp::HandlerTwo->new(), | ||
| 33 | ], | ||
| 34 | ); | ||
| 35 | |||
| 36 | my $application = Patterns::ChainOfResponsibility::Application->new(%opts); | ||
| 37 | $application->process(@args); | ||
| 38 | |||
| 39 | =head1 DESCRIPTION | ||
| 40 | |||
| 41 | A wrapper application that contains a bunch of instances of | ||
| 42 | L<Patterns::ChainOfResponsibility::Role::Handler>. | ||
| 43 | |||
| 44 | =head1 AUTHOR | ||
| 45 | |||
| 46 | John Napiorkowski C<< <jnapiork@cpan.org> >> | ||
| 47 | |||
| 48 | =head1 LICENSE & COPYRIGHT | ||
| 49 | |||
| 50 | Copyright 2011, John Napiorkowski C<< <jjnapiork@cpan.org> >> | ||
| 51 | |||
| 52 | This program is free software; you can redistribute it and/or modify | ||
| 53 | it under the same terms as Perl itself. | ||
| 54 | |||
| 55 | =cut | ||
| 56 | |||
| 57 | 2 | 1; | |