A little POD
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Service / WithContext.pm
CommitLineData
5fabf3ec 1package Catalyst::Service::WithContext;
2use Moose::Role;
3
4use Bread::Board::Types;
5
6with 'Bread::Board::Service';
7
8has accept_context_sub => (
9 is => 'ro',
10 isa => 'Str',
11 default => 'ACCEPT_CONTEXT',
12);
13
14around 'get' => sub {
38215fbf 15 my ( $orig, $self, %params ) = @_;
5fabf3ec 16
38215fbf 17 my $context = delete $params{context};
18
19 my $instance = $self->$orig(%params);
5fabf3ec 20 my $ac_sub = $self->accept_context_sub;
21
0d77134e 22 if ( $instance->can($ac_sub) ) {
38215fbf 23 return $instance->$ac_sub( @$context );
5fabf3ec 24 }
25
26 return $instance;
27};
28
29no Moose::Role;
301;
bf3c8088 31
32__END__
33
34=pod
35
36=head1 NAME
37
38Catalyst::Service::WithContext
39
40=head1 DESCRIPTION
41
42=head1 METHODS
43
44=over 4
45
46=item B<accept_context_sub>
47
48=item B<get>
49
50=back
51
52=head1 AUTHOR
53
54André Walker
55
56=head1 LICENSE
57
58This library is free software; you can redistribute it and/or modify
59it under the same terms as Perl itself.
60
61=cut