Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

call extracted method from callback manipulation methods

  • Loading branch information...
commit 72be280ffe1f548fcdbff5f85b69b47c230722a7 1 parent 35c4a2c
Aaron Patterson tenderlove authored
Showing with 8 additions and 6 deletions.
  1. +8 −6 activesupport/lib/active_support/callbacks.rb
14 activesupport/lib/active_support/callbacks.rb
View
@@ -446,12 +446,10 @@ def normalize_callback_params(name, filters, block) # :nodoc:
# This is used internally to append, prepend and skip callbacks to the
# CallbackChain.
- def __update_callbacks(name, filters, block) #:nodoc:
- type, filters, options = normalize_callback_params(name, filters, block)
-
+ def __update_callbacks(name) #:nodoc:
([self] + ActiveSupport::DescendantsTracker.descendants(self)).reverse.each do |target|
chain = target.send("_#{name}_callbacks")
- yield target, chain.dup, type, filters, options
+ yield target, chain.dup
target.__reset_runner(name)
end
end
@@ -494,7 +492,9 @@ def __update_callbacks(name, filters, block) #:nodoc:
def set_callback(name, *filter_list, &block)
mapped = nil
- __update_callbacks(name, filter_list, block) do |target, chain, type, filters, options|
+ type, filters, options = normalize_callback_params(name, filter_list, block)
+
+ __update_callbacks(name) do |target, chain|
mapped ||= filters.map do |filter|
Callback.build(chain, filter, type, options.dup, self)
end
@@ -513,7 +513,9 @@ def set_callback(name, *filter_list, &block)
# skip_callback :validate, :before, :check_membership, if: -> { self.age > 18 }
# end
def skip_callback(name, *filter_list, &block)
- __update_callbacks(name, filter_list, block) do |target, chain, type, filters, options|
+ type, filters, options = normalize_callback_params(name, filter_list, block)
+
+ __update_callbacks(name) do |target, chain|
filters.each do |filter|
filter = chain.find {|c| c.matches?(type, filter) }
Please sign in to comment.
Something went wrong with that request. Please try again.