diff options
author | José Valim <jose.valim@plataformatec.com.br> | 2012-02-03 06:23:00 -0800 |
---|---|---|
committer | José Valim <jose.valim@plataformatec.com.br> | 2012-02-03 06:23:00 -0800 |
commit | d709b124d1815340f4a2229b05362ea37298288f (patch) | |
tree | 2721da0d71dff7a50023d0229adb3009e3d0da7a | |
parent | 5325adc9cac99ba246869b714cad85d0f4e4d0d0 (diff) | |
parent | 1c61f7e6cb2882907fa85fabbf147937f5cc07bf (diff) | |
download | rails-d709b124d1815340f4a2229b05362ea37298288f.tar.gz rails-d709b124d1815340f4a2229b05362ea37298288f.tar.bz2 rails-d709b124d1815340f4a2229b05362ea37298288f.zip |
Merge pull request #4865 from bogdan/deprecate_per_key
AC::Callbacks: remove usage of :per_key option from filters
-rw-r--r-- | actionpack/lib/abstract_controller/callbacks.rb | 10 | ||||
-rw-r--r-- | activesupport/lib/active_support/callbacks.rb | 4 |
2 files changed, 6 insertions, 8 deletions
diff --git a/actionpack/lib/abstract_controller/callbacks.rb b/actionpack/lib/abstract_controller/callbacks.rb index fffe3edac2..d61475c844 100644 --- a/actionpack/lib/abstract_controller/callbacks.rb +++ b/actionpack/lib/abstract_controller/callbacks.rb @@ -21,11 +21,9 @@ module AbstractController module ClassMethods # If :only or :except are used, convert the options into the - # primitive form (:per_key) used by ActiveSupport::Callbacks. + # :unless and :if options of ActiveSupport::Callbacks. # The basic idea is that :only => :index gets converted to - # :if => proc {|c| c.action_name == "index" }, but that the - # proc is only evaluated once per action for the lifetime of - # a Rails process. + # :if => proc {|c| c.action_name == "index" }. # # ==== Options # * <tt>only</tt> - The callback should be run only for this action @@ -33,11 +31,11 @@ module AbstractController def _normalize_callback_options(options) if only = options[:only] only = Array(only).map {|o| "action_name == '#{o}'"}.join(" || ") - options[:per_key] = {:if => only} + options[:if] = Array(options[:if]) << only end if except = options[:except] except = Array(except).map {|e| "action_name == '#{e}'"}.join(" || ") - options[:per_key] = {:unless => except} + options[:unless] = Array(options[:unless]) << except end end diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb index 5eaeac2cb3..bc6bd55a45 100644 --- a/activesupport/lib/active_support/callbacks.rb +++ b/activesupport/lib/active_support/callbacks.rb @@ -136,8 +136,8 @@ module ActiveSupport end def _update_filter(filter_options, new_options) - filter_options[:if].push(new_options[:unless]) if new_options.key?(:unless) - filter_options[:unless].push(new_options[:if]) if new_options.key?(:if) + filter_options[:if].concat(Array(new_options[:unless])) if new_options.key?(:unless) + filter_options[:unless].concat(Array(new_options[:if])) if new_options.key?(:if) end def recompile!(_options, _per_key) |