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