diff options
author | Joshua Peek <josh@joshpeek.com> | 2008-12-28 15:07:17 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2008-12-28 15:07:17 -0600 |
commit | 1e45818a622405e720a4529795f8be2f11660361 (patch) | |
tree | 051a3175e52fedbcba931010852734f1e33839bc /activesupport/lib | |
parent | 3b92b141fd0759476690a174d5e2f8f0f2d9f1b7 (diff) | |
download | rails-1e45818a622405e720a4529795f8be2f11660361.tar.gz rails-1e45818a622405e720a4529795f8be2f11660361.tar.bz2 rails-1e45818a622405e720a4529795f8be2f11660361.zip |
Allow multiple conditions for callbacks [#1627 state:resolved]
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/callbacks.rb | 9 |
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 |