Skip to content

Instantly share code, notes, and snippets.

@hidek
Created May 8, 2009 02:27
Show Gist options
  • Save hidek/108568 to your computer and use it in GitHub Desktop.
Save hidek/108568 to your computer and use it in GitHub Desktop.
*** lib/Catalyst/Plugin/FormValidator/Simple/Auto.pm 2009-05-08 11:16:57.000000000 +0900
--- lib/Catalyst/Plugin/FormValidator/Simple/Auto.pm.new 2009-05-08 11:23:50.000000000 +0900
***************
*** 7,12 ****
--- 7,13 ----
use UNIVERSAL::isa;
use YAML;
use FormValidator::Simple;
+ use MRO::Compat;
our $VERSION = '0.17';
***************
*** 170,183 ****
# XXX: replace messages. ponder about hash merging
$config->{messages} = $messages if $messages;
# fix plugin order
{
no strict 'refs';
my $pkg = __PACKAGE__;
@{"$c\::ISA"} = ( $pkg, grep !/^$pkg$/, @{"$c\::ISA"} );
}
!
! $c->NEXT::setup(@_);
}
=head2 prepare
--- 171,193 ----
# XXX: replace messages. ponder about hash merging
$config->{messages} = $messages if $messages;
+ $c->next::method(@_);
+ }
+
+ =head2 setup_finalize
+
+ =cut
+
+ sub setup_finalize {
+ my $c = shift;
+
# fix plugin order
{
no strict 'refs';
my $pkg = __PACKAGE__;
@{"$c\::ISA"} = ( $pkg, grep !/^$pkg$/, @{"$c\::ISA"} );
}
! $c->next::method(@_);
}
=head2 prepare
***************
*** 185,198 ****
=cut
sub prepare {
! my $c = shift->NEXT::prepare(@_);
if ( my $profile = $c->config->{validator}{profiles}{ $c->action->reverse } ) {
$c->validator_profile( $c->action->reverse );
$c->form(%$profile);
}
! $c
}
=head2 forward
--- 195,208 ----
=cut
sub prepare {
! my $c = shift->next::method(@_);
if ( my $profile = $c->config->{validator}{profiles}{ $c->action->reverse } ) {
$c->validator_profile( $c->action->reverse );
$c->form(%$profile);
}
! $c;
}
=head2 forward
***************
*** 203,211 ****
my $c = shift;
my $action = $c->dispatcher->_invoke_as_path($c, @_);
- no warnings 'once';
- local $NEXT::NEXT{ $c, 'forward' };
-
my $res;
if ( my $profile = $c->config->{validator}{profiles}{ $action } ) {
# first time validation
--- 213,218 ----
***************
*** 213,219 ****
$c->{validator_profile} = $action;
$c->form(%$profile);
! $res = $c->NEXT::forward(@_);
}
else {
# don't override validator stuffs when not first time validation
--- 220,226 ----
$c->{validator_profile} = $action;
$c->form(%$profile);
! $res = $c->next::method(@_);
}
else {
# don't override validator stuffs when not first time validation
***************
*** 221,231 ****
local $c->{validator_profile} = $action;
$c->form(%$profile);
! $res = $c->NEXT::forward(@_);
}
}
else {
! $res = $c->NEXT::forward(@_);
}
$res;
--- 228,238 ----
local $c->{validator_profile} = $action;
$c->form(%$profile);
! $res = $c->next::method(@_);
}
}
else {
! $res = $c->next::method(@_);
}
$res;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment