method
define_callbacks
v2.3.8 -
Show latest stable
-
0 notes -
Class: ActiveSupport::Callbacks::ClassMethods
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0 (0)
- 2.2.1 (0)
- 2.3.8 (0)
- 3.0.0 (29)
- 3.0.9 (-2)
- 3.1.0 (7)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (0)
- 4.1.8 (1)
- 4.2.1 (1)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (2)
- 5.1.7
- 5.2.3
- 6.0.0
- 6.1.3.1
- 6.1.7.7
- 7.0.0
- 7.1.3.2
- 7.1.3.4
- What's this?
define_callbacks(*callbacks)
public
Hide source
# File activesupport/lib/active_support/callbacks.rb, line 205 def define_callbacks(*callbacks) callbacks.each do |callback| class_eval "def self.\#{callback}(*methods, &block) # def self.before_save(*methods, &block)\ncallbacks = CallbackChain.build(:\#{callback}, *methods, &block) # callbacks = CallbackChain.build(:before_save, *methods, &block)\n@\#{callback}_callbacks ||= CallbackChain.new # @before_save_callbacks ||= CallbackChain.new\n@\#{callback}_callbacks.concat callbacks # @before_save_callbacks.concat callbacks\nend # end\n#\ndef self.\#{callback}_callback_chain # def self.before_save_callback_chain\n@\#{callback}_callbacks ||= CallbackChain.new # @before_save_callbacks ||= CallbackChain.new\n#\nif superclass.respond_to?(:\#{callback}_callback_chain) # if superclass.respond_to?(:before_save_callback_chain)\nCallbackChain.new( # CallbackChain.new(\nsuperclass.\#{callback}_callback_chain + # superclass.before_save_callback_chain +\n@\#{callback}_callbacks # @before_save_callbacks\n) # )\nelse # else\n@\#{callback}_callbacks # @before_save_callbacks\nend # end\nend # end\n" end end