subclassing Bread::Board::Service to replace _filter_component
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Service / WithContext.pm
CommitLineData
5fabf3ec 1package Catalyst::Service::WithContext;
2use Moose::Role;
3
4use Bread::Board::Types;
5
6with 'Bread::Board::Service';
7
8has accept_context_sub => (
9 is => 'ro',
10 isa => 'Str',
11 default => 'ACCEPT_CONTEXT',
12);
13
14around 'get' => sub {
15 my ( $orig, $self, @params ) = @_;
16
17 my $instance = $self->$orig();
18 my $ac_sub = $self->accept_context_sub;
19
20 if ( $instance->can($ac_sub) ) {
21 return $instance->$ac_sub( @params );
22 }
23
24 return $instance;
25};
26
27no Moose::Role;
281;