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