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