madness.
[catagits/Catalyst-Runtime.git] / lib / Catalyst / IOC / Service / WithAcceptContext.pm
CommitLineData
a6c13ff4 1package Catalyst::IOC::Service::WithAcceptContext;
5fabf3ec 2use Moose::Role;
3
5fabf3ec 4has accept_context_sub => (
5 is => 'ro',
6 isa => 'Str',
7 default => 'ACCEPT_CONTEXT',
8);
9
8f5f2108 10around 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
9084f394 19 if ( $accept_context_args && $instance->can($ac_sub) ) {
fce8d46e 20 # FIXME - MADNESS!
21 # how the heck does this warn CODE???????????
22 warn ref $accept_context_args if ref $accept_context_args ne 'ARRAY';
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