Commit | Line | Data |
---|---|---|
a6c13ff4 | 1 | package Catalyst::IOC::Service::WithAcceptContext; |
5fabf3ec | 2 | use Moose::Role; |
3 | ||
5fabf3ec | 4 | has accept_context_sub => ( |
5 | is => 'ro', | |
6 | isa => 'Str', | |
7 | default => 'ACCEPT_CONTEXT', | |
8 | ); | |
9 | ||
8f5f2108 | 10 | around get => sub { |
11 | my $orig = shift; | |
12 | my $self = shift; | |
38215fbf | 13 | |
b489e5df | 14 | my $accept_context_args = $self->param('accept_context_args'); |
17fe1041 | 15 | my $ac_sub = $self->accept_context_sub; |
5fabf3ec | 16 | |
b489e5df | 17 | my $instance = $self->$orig(@_); |
18 | ||
ff0e9735 | 19 | if ( $instance->can($ac_sub) ) { |
4f38bf4b | 20 | return $instance->$ac_sub( @$accept_context_args ); |
5fabf3ec | 21 | } |
22 | ||
23 | return $instance; | |
24 | }; | |
25 | ||
26 | no Moose::Role; | |
27 | 1; | |
bf3c8088 | 28 | |
29 | __END__ | |
30 | ||
31 | =pod | |
32 | ||
33 | =head1 NAME | |
34 | ||
ff0e9735 | 35 | Catalyst::IOC::Service::WithAcceptContext |
bf3c8088 | 36 | |
37 | =head1 DESCRIPTION | |
38 | ||
1ab07ed4 | 39 | =head1 ATTRIBUTES |
bf3c8088 | 40 | |
1ab07ed4 | 41 | =head2 accept_context_sub |
bf3c8088 | 42 | |
e8ed391e | 43 | =head1 AUTHORS |
bf3c8088 | 44 | |
e8ed391e | 45 | Catalyst Contributors, see Catalyst.pm |
bf3c8088 | 46 | |
e8ed391e | 47 | =head1 COPYRIGHT |
bf3c8088 | 48 | |
e8ed391e | 49 | This library is free software. You can redistribute it and/or modify it under |
50 | the same terms as Perl itself. | |
bf3c8088 | 51 | |
52 | =cut |