Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #8157 from steveklabnik/remove_callback_duplication

Removing duplication in callback normalization.
  • Loading branch information...
commit 52538dda134fc287d0d903c0b3e17e5c0f9177a9 2 parents dbb39e5 + c4e3b0c
@rafaelfranca rafaelfranca authored
Showing with 8 additions and 7 deletions.
  1. +8 −7 actionpack/lib/abstract_controller/callbacks.rb
View
15 actionpack/lib/abstract_controller/callbacks.rb
@@ -29,13 +29,14 @@ module ClassMethods
# * <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
Please sign in to comment.
Something went wrong with that request. Please try again.