method
define_callbacks
v2.1.0 -
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)\ncallbacks = CallbackChain.build(:\#{callback}, *methods, &block)\n(@\#{callback}_callbacks ||= CallbackChain.new).concat callbacks\nend\n\ndef self.\#{callback}_callback_chain\n@\#{callback}_callbacks ||= CallbackChain.new\n\nif superclass.respond_to?(:\#{callback}_callback_chain)\nCallbackChain.new(superclass.\#{callback}_callback_chain + @\#{callback}_callbacks)\nelse\n@\#{callback}_callbacks\nend\nend\n" end end