aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/callbacks.rb
diff options
context:
space:
mode:
authorRyan Wallace <rywall@gmail.com>2018-02-24 21:32:11 +0100
committerRyan Wallace <rywall@gmail.com>2018-02-24 21:34:05 +0100
commit4efba09e88c5f4cdd78102c1d43ceea2c242a435 (patch)
tree4c0b710700123a7c9bc4693ac5755aa7ac81e4ef /activesupport/lib/active_support/callbacks.rb
parent56640b4de4e3245b087ca16e0f3bec751c6d6fb7 (diff)
downloadrails-4efba09e88c5f4cdd78102c1d43ceea2c242a435.tar.gz
rails-4efba09e88c5f4cdd78102c1d43ceea2c242a435.tar.bz2
rails-4efba09e88c5f4cdd78102c1d43ceea2c242a435.zip
No need to define methods on descendants.
Addresses feedback from https://github.com/rails/rails/pull/31913#issuecomment-365983580
Diffstat (limited to 'activesupport/lib/active_support/callbacks.rb')
-rw-r--r--activesupport/lib/active_support/callbacks.rb36
1 files changed, 18 insertions, 18 deletions
diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb
index cece3eb19f..de42a075e1 100644
--- a/activesupport/lib/active_support/callbacks.rb
+++ b/activesupport/lib/active_support/callbacks.rb
@@ -806,30 +806,30 @@ module ActiveSupport
def define_callbacks(*names)
options = names.extract_options!
- ([self] + ActiveSupport::DescendantsTracker.descendants(self)).each do |target|
- names.each do |name|
- name = name.to_sym
+ names.each do |name|
+ name = name.to_sym
+ ([self] + ActiveSupport::DescendantsTracker.descendants(self)).each do |target|
target.set_callbacks name, CallbackChain.new(name, options)
+ end
- target.module_eval <<-RUBY, __FILE__, __LINE__ + 1
- def _run_#{name}_callbacks(&block)
- run_callbacks #{name.inspect}, &block
- end
+ module_eval <<-RUBY, __FILE__, __LINE__ + 1
+ def _run_#{name}_callbacks(&block)
+ run_callbacks #{name.inspect}, &block
+ end
- def self._#{name}_callbacks
- get_callbacks(#{name.inspect})
- end
+ def self._#{name}_callbacks
+ get_callbacks(#{name.inspect})
+ end
- def self._#{name}_callbacks=(value)
- set_callbacks(#{name.inspect}, value)
- end
+ def self._#{name}_callbacks=(value)
+ set_callbacks(#{name.inspect}, value)
+ end
- def _#{name}_callbacks
- __callbacks[#{name.inspect}]
- end
- RUBY
- end
+ def _#{name}_callbacks
+ __callbacks[#{name.inspect}]
+ end
+ RUBY
end
end