Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removing duplication in callback normalization.

These two things were 100% identical.
  • Loading branch information...
commit c4e3b0cd8b3208bf692a5e278d76c9e26745a4eb 1 parent 6710f05
@steveklabnik 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.