X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Controller-DBIC-API.git;a=blobdiff_plain;f=lib%2FCatalyst%2FController%2FDBIC%2FAPI%2FValidator%2FVisitor.pm;fp=lib%2FCatalyst%2FController%2FDBIC%2FAPI%2FValidator%2FVisitor.pm;h=f29c4207f61f566406e50f4b7e263f6f1e7b9a57;hp=725f4a18551dfcba86abece3c4da21df4b3e2e31;hb=8ea592cbf64db6d549685f3962c88d925fe7cdb1;hpb=5fca1d92a1bbeb68d4c810e7e779cfb8877dff60 diff --git a/lib/Catalyst/Controller/DBIC/API/Validator/Visitor.pm b/lib/Catalyst/Controller/DBIC/API/Validator/Visitor.pm index 725f4a1..f29c420 100644 --- a/lib/Catalyst/Controller/DBIC/API/Validator/Visitor.pm +++ b/lib/Catalyst/Controller/DBIC/API/Validator/Visitor.pm @@ -1,4 +1,5 @@ package Catalyst::Controller::DBIC::API::Validator::Visitor; + #ABSTRACT: Provides validation services for inbound requests against whitelisted parameters use Moose; use namespace::autoclean; @@ -14,20 +15,16 @@ DATA_DPATH_VALIDATOR_DEBUG to a true value. use constant DEBUG => $ENV{DATA_DPATH_VALIDATOR_DEBUG} || 0; -around visit_array => sub -{ - my ($orig, $self, $array) = @_; +around visit_array => sub { + my ( $orig, $self, $array ) = @_; $self->dive(); - warn 'ARRAY: '. $self->current_template if DEBUG; - if(@$array == 1 && $array->[0] eq '*') - { + warn 'ARRAY: ' . $self->current_template if DEBUG; + if ( @$array == 1 && $array->[0] eq '*' ) { $self->append_text('[reftype eq "HASH" ]'); - $self->add_template($self->current_template); + $self->add_template( $self->current_template ); } - else - { - if($self->current_template =~ /\/$/) - { + else { + if ( $self->current_template =~ /\/$/ ) { my $temp = $self->current_template; $self->reset_template(); $temp =~ s/\/$//; @@ -38,67 +35,58 @@ around visit_array => sub $self->rise(); }; -sub visit_array_entry -{ +sub visit_array_entry { + # to make release-unused-vars.t happy #my ($self, $elem, $index, $array) = @_; - my ($self, $elem) = @_; + my ( $self, $elem ) = @_; $self->dive(); - warn 'ARRAYENTRY: '. $self->current_template if DEBUG; - if(!ref($elem)) - { - $self->append_text($elem . '/*'); - $self->add_template($self->current_template); + warn 'ARRAYENTRY: ' . $self->current_template if DEBUG; + if ( !ref($elem) ) { + $self->append_text( $elem . '/*' ); + $self->add_template( $self->current_template ); } - elsif(ref($elem) eq 'HASH') - { + elsif ( ref($elem) eq 'HASH' ) { $self->visit($elem); } $self->rise(); $self->value_type('NONE'); -}; +} -around visit_hash => sub -{ - my ($orig, $self, $hash) = @_; +around visit_hash => sub { + my ( $orig, $self, $hash ) = @_; $self->dive(); - if($self->current_template =~ /\/$/) - { + if ( $self->current_template =~ /\/$/ ) { my $temp = $self->current_template; $self->reset_template(); $temp =~ s/\/$//; $self->append_text($temp); } - warn 'HASH: '. $self->current_template if DEBUG; + warn 'HASH: ' . $self->current_template if DEBUG; $self->$orig($hash); $self->rise(); }; -around visit_value => sub -{ - my ($orig, $self, $val) = @_; +around visit_value => sub { + my ( $orig, $self, $val ) = @_; - if($self->value_type eq 'NONE') - { + if ( $self->value_type eq 'NONE' ) { $self->dive(); - $self->append_text($val . '/*'); - $self->add_template($self->current_template); + $self->append_text( $val . '/*' ); + $self->add_template( $self->current_template ); warn 'VALUE: ' . $self->current_template if DEBUG; $self->rise(); } - elsif($self->value_type eq 'HashKey') - { + elsif ( $self->value_type eq 'HashKey' ) { $self->append_text($val); warn 'VALUE: ' . $self->current_template if DEBUG; } - else - { + else { $self->$orig($val); } }; - __PACKAGE__->meta->make_immutable; -1; \ No newline at end of file +1;