Fixed WithAcceptContext to use params correctly
[catagits/Catalyst-Runtime.git] / lib / Catalyst / IOC / Service / WithAcceptContext.pm
CommitLineData
a6c13ff4 1package Catalyst::IOC::Service::WithAcceptContext;
5fabf3ec 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 {
17fe1041 13 my $orig = shift;
14 my $self = shift;
5fabf3ec 15
17fe1041 16 my $instance = $self->$orig(@_);
38215fbf 17
17fe1041 18 my $accept_context_args = $self->param('accept_context_args');
19 my $ac_sub = $self->accept_context_sub;
5fabf3ec 20
a42c4b8a 21 if ( $accept_context_args && $instance->can($ac_sub) ) {
4f38bf4b 22 return $instance->$ac_sub( @$accept_context_args );
5fabf3ec 23 }
24
25 return $instance;
26};
27
28no Moose::Role;
291;
bf3c8088 30
31__END__
32
33=pod
34
35=head1 NAME
36
17fe1041 37Catalyst::Service::WithAcceptContext
bf3c8088 38
39=head1 DESCRIPTION
40
41=head1 METHODS
42
e8ed391e 43=over
bf3c8088 44
45=item B<accept_context_sub>
46
47=item B<get>
48
49=back
50
e8ed391e 51=head1 AUTHORS
bf3c8088 52
e8ed391e 53Catalyst Contributors, see Catalyst.pm
bf3c8088 54
e8ed391e 55=head1 COPYRIGHT
bf3c8088 56
e8ed391e 57This library is free software. You can redistribute it and/or modify it under
58the same terms as Perl itself.
bf3c8088 59
60=cut