From 35c4a2ca95848bf03839ebb58a98d93189c5d3aa Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 13 May 2013 14:11:09 -0700 Subject: extract callback param munging --- activesupport/lib/active_support/callbacks.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb index 92b57ee1ce..cc0fe51598 100644 --- a/activesupport/lib/active_support/callbacks.rb +++ b/activesupport/lib/active_support/callbacks.rb @@ -437,12 +437,17 @@ module ActiveSupport __callback_runner_name_cache[kind] end - # This is used internally to append, prepend and skip callbacks to the - # CallbackChain. - def __update_callbacks(name, filters, block) #:nodoc: + def normalize_callback_params(name, filters, block) # :nodoc: type = CALLBACK_FILTER_TYPES.include?(filters.first) ? filters.shift : :before options = filters.last.is_a?(Hash) ? filters.pop : {} filters.unshift(block) if block + [type, filters, options] + end + + # 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) ([self] + ActiveSupport::DescendantsTracker.descendants(self)).reverse.each do |target| chain = target.send("_#{name}_callbacks") -- cgit v1.2.3