From 72be280ffe1f548fcdbff5f85b69b47c230722a7 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 13 May 2013 14:14:50 -0700 Subject: call extracted method from callback manipulation methods --- activesupport/lib/active_support/callbacks.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb index cc0fe51598..8ac49ec4b6 100644 --- a/activesupport/lib/active_support/callbacks.rb +++ b/activesupport/lib/active_support/callbacks.rb @@ -446,12 +446,10 @@ module ActiveSupport # 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 @@ module ActiveSupport 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 @@ module ActiveSupport # 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) } -- cgit v1.2.3