ACCEPT_CONTEXT wasnt getting the args
[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
8f5f2108 12around get => sub {
13 my $orig = shift;
14 my $self = shift;
15 my %params = @_;
5fabf3ec 16
17fe1041 17 my $instance = $self->$orig(@_);
38215fbf 18
8f5f2108 19 my $accept_context_args = $params{accept_context_args};
17fe1041 20 my $ac_sub = $self->accept_context_sub;
5fabf3ec 21
ff0e9735 22 if ( $instance->can($ac_sub) ) {
4f38bf4b 23 return $instance->$ac_sub( @$accept_context_args );
5fabf3ec 24 }
25
26 return $instance;
27};
28
29no Moose::Role;
301;
bf3c8088 31
32__END__
33
34=pod
35
36=head1 NAME
37
ff0e9735 38Catalyst::IOC::Service::WithAcceptContext
bf3c8088 39
40=head1 DESCRIPTION
41
1ab07ed4 42=head1 ATTRIBUTES
bf3c8088 43
1ab07ed4 44=head2 accept_context_sub
bf3c8088 45
e8ed391e 46=head1 AUTHORS
bf3c8088 47
e8ed391e 48Catalyst Contributors, see Catalyst.pm
bf3c8088 49
e8ed391e 50=head1 COPYRIGHT
bf3c8088 51
e8ed391e 52This library is free software. You can redistribute it and/or modify it under
53the same terms as Perl itself.
bf3c8088 54
55=cut