aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-05-13 14:14:50 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-05-13 14:14:50 -0700
commit72be280ffe1f548fcdbff5f85b69b47c230722a7 (patch)
tree8aed2cef997b1890616582520523ff079f4f0a73 /activesupport
parent35c4a2ca95848bf03839ebb58a98d93189c5d3aa (diff)
downloadrails-72be280ffe1f548fcdbff5f85b69b47c230722a7.tar.gz
rails-72be280ffe1f548fcdbff5f85b69b47c230722a7.tar.bz2
rails-72be280ffe1f548fcdbff5f85b69b47c230722a7.zip
call extracted method from callback manipulation methods
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/callbacks.rb14
1 files changed, 8 insertions, 6 deletions
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) }