diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-05-13 14:11:09 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-05-13 14:11:09 -0700 |
commit | 35c4a2ca95848bf03839ebb58a98d93189c5d3aa (patch) | |
tree | 8a3272784401b146868217d9cff29e947790cbeb | |
parent | 0b9b132e3293c56fb37a612c51a883df26a2b6c7 (diff) | |
download | rails-35c4a2ca95848bf03839ebb58a98d93189c5d3aa.tar.gz rails-35c4a2ca95848bf03839ebb58a98d93189c5d3aa.tar.bz2 rails-35c4a2ca95848bf03839ebb58a98d93189c5d3aa.zip |
extract callback param munging
-rw-r--r-- | activesupport/lib/active_support/callbacks.rb | 11 |
1 files changed, 8 insertions, 3 deletions
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") |