prepare for 0.011
[catagits/CatalystX-Declare.git] / lib / CatalystX / Declare / Action / CatchValidationError.pm
CommitLineData
5fb5cef1 1use MooseX::Declare;
2
3role CatalystX::Declare::Action::CatchValidationError {
4
ed4a2203 5 use aliased 'Moose::Meta::TypeConstraint';
6
7 has method_type_constraint => (
8 is => 'rw',
9 isa => TypeConstraint,
10 handles => {
11 _check_action_arguments => 'check',
12 },
13 );
14
15 has controller_instance => (
16 is => 'rw',
17 isa => 'Catalyst::Controller',
18 weak_ref => 1,
19 );
20
21 around match (Object $ctx) {
22
23 return
24 unless $self->$orig($ctx);
25 return 1
26 unless $self->method_type_constraint;
27
28 my @args = ($self->controller_instance, $ctx, @{ $ctx->req->args });
29 my $tc = $self->method_type_constraint;
30 my $ret = $self->_check_action_arguments(\@args);
31
32 return $ret;
5fb5cef1 33 }
34}