aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Klabnik <steve@steveklabnik.com>2012-11-09 14:41:11 +0100
committerSteve Klabnik <steve@steveklabnik.com>2012-11-09 14:43:03 +0100
commitc4e3b0cd8b3208bf692a5e278d76c9e26745a4eb (patch)
tree68d21a94cef870e0f2137a5d5fb7b82e76d8e82d
parent6710f057f9033aec2ef62b961b9a2000a2d499e5 (diff)
downloadrails-c4e3b0cd8b3208bf692a5e278d76c9e26745a4eb.tar.gz
rails-c4e3b0cd8b3208bf692a5e278d76c9e26745a4eb.tar.bz2
rails-c4e3b0cd8b3208bf692a5e278d76c9e26745a4eb.zip
Removing duplication in callback normalization.
These two things were 100% identical.
-rw-r--r--actionpack/lib/abstract_controller/callbacks.rb15
1 files changed, 8 insertions, 7 deletions
diff --git a/actionpack/lib/abstract_controller/callbacks.rb b/actionpack/lib/abstract_controller/callbacks.rb
index 5705ab590c..02ac111392 100644
--- a/actionpack/lib/abstract_controller/callbacks.rb
+++ b/actionpack/lib/abstract_controller/callbacks.rb
@@ -29,13 +29,14 @@ module AbstractController
# * <tt>only</tt> - The callback should be run only for this action
# * <tt>except</tt> - The callback should be run for all actions except this action
def _normalize_callback_options(options)
- if only = options[:only]
- only = Array(only).map {|o| "action_name == '#{o}'"}.join(" || ")
- options[:if] = Array(options[:if]) << only
- end
- if except = options[:except]
- except = Array(except).map {|e| "action_name == '#{e}'"}.join(" || ")
- options[:unless] = Array(options[:unless]) << except
+ _normalize_callback_option(options, :only, :if)
+ _normalize_callback_option(options, :except, :unless)
+ end
+
+ def _normalize_callback_option(options, from, to) # :nodoc:
+ if from = options[from]
+ from = Array(from).map {|o| "action_name == '#{o}'"}.join(" || ")
+ options[to] = Array(options[to]) << from
end
end