aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2008-12-28 15:07:17 -0600
committerJoshua Peek <josh@joshpeek.com>2008-12-28 15:07:17 -0600
commit1e45818a622405e720a4529795f8be2f11660361 (patch)
tree051a3175e52fedbcba931010852734f1e33839bc /activesupport/lib/active_support
parent3b92b141fd0759476690a174d5e2f8f0f2d9f1b7 (diff)
downloadrails-1e45818a622405e720a4529795f8be2f11660361.tar.gz
rails-1e45818a622405e720a4529795f8be2f11660361.tar.bz2
rails-1e45818a622405e720a4529795f8be2f11660361.zip
Allow multiple conditions for callbacks [#1627 state:resolved]
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/callbacks.rb9
1 files changed, 2 insertions, 7 deletions
diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb
index 992827f7f4..86e66e0588 100644
--- a/activesupport/lib/active_support/callbacks.rb
+++ b/activesupport/lib/active_support/callbacks.rb
@@ -192,13 +192,8 @@ module ActiveSupport
end
def should_run_callback?(*args)
- if options[:if]
- evaluate_method(options[:if], *args)
- elsif options[:unless]
- !evaluate_method(options[:unless], *args)
- else
- true
- end
+ [options[:if]].flatten.compact.all? { |a| evaluate_method(a, *args) } &&
+ ![options[:unless]].flatten.compact.any? { |a| evaluate_method(a, *args) }
end
end