Module: ActiveSupport::Callbacks::ClassMethods
- Defined in:
- lib/active_support/callbacks.rb
Instance Method Summary collapse
Instance Method Details
#define_callbacks(*callbacks) ⇒ Object
end
end
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
# File 'lib/active_support/callbacks.rb', line 231 def define_callbacks(*callbacks) callbacks.each do |callback| class_eval <<-"end_eval" def self.#{callback}(*methods, &block) callbacks = CallbackChain.build(:#{callback}, *methods, &block) (@#{callback}_callbacks ||= CallbackChain.new).concat callbacks end def self.#{callback}_callback_chain @#{callback}_callbacks ||= CallbackChain.new if superclass.respond_to?(:#{callback}_callback_chain) CallbackChain.new(superclass.#{callback}_callback_chain + @#{callback}_callbacks) else @#{callback}_callbacks end end end_eval end end |