[Jifty-commit] r3429 - Jifty-DBI/trunk/lib/Jifty/DBI/Class

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sun Jun 10 20:29:57 EDT 2007


Author: clkao
Date: Sun Jun 10 20:29:57 2007
New Revision: 3429

Modified:
   Jifty-DBI/trunk/lib/Jifty/DBI/Class/Trigger.pm

Log:
* Don't use $_ when calling triggers.
* in add_trigger, Don't assume it's 2-arg call when $_[1] is CODE.


Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Class/Trigger.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Class/Trigger.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Class/Trigger.pm	Sun Jun 10 20:29:57 2007
@@ -25,13 +25,12 @@
 
     my $triggers = __fetch_triggers($proto);
 
-    if (ref($_[1]) eq 'CODE') { 
-
-    while (my($when, $code) = splice @_, 0, 2) {
-        __validate_triggerpoint($proto, $when);
-        Carp::croak('add_trigger() needs coderef') unless ref($code) eq 'CODE';
-        push @{$triggers->{$when}}, [$code, undef];
-    }
+    if ($#_ == 1 && ref($_[1]) eq 'CODE') { 
+	while (my($when, $code) = splice @_, 0, 2) {
+            __validate_triggerpoint($proto, $when);
+            Carp::croak('add_trigger() needs coderef') unless ref($code) eq 'CODE';
+            push @{$triggers->{$when}}, [$code, undef];
+        }
     }
     elsif (grep {'name'} @_) {
         my %args = ( name => undef, callback => undef, abortable => undef, @_);
@@ -68,12 +67,11 @@
     $result_store->{'_class_trigger_results'} = [];
 
     if (my @triggers = __fetch_all_triggers($self, $when)) { # any triggers?
-        for (@triggers) {
-              my @return = $_->[0]->($self, @_);
+        for my $trig (@triggers) {
+              my @return = $trig->[0]->($self, @_);
                 push @{$result_store->{'_class_trigger_results'}}, \@return;
-                return undef if ($_->[1] and not $return[0]); # only abort on false values.
-         
-    }
+                return undef if ($trig->[1] and not $return[0]); # only abort on false values.
+        }
     }
     else {
         # if validation is enabled we can only add valid trigger points


More information about the Jifty-commit mailing list