class CallbacksTest::Record

Public Class Methods

after_save(*filters, &blk) click to toggle source
# File activesupport/test/callbacks_test.rb, line 15
def self.after_save(*filters, &blk)
  set_callback(:save, :after, *filters, &blk)
end
before_save(*filters, &blk) click to toggle source
# File activesupport/test/callbacks_test.rb, line 11
def self.before_save(*filters, &blk)
  set_callback(:save, :before, *filters, &blk)
end
callback_object(callback_method) click to toggle source
# File activesupport/test/callbacks_test.rb, line 32
def callback_object(callback_method)
  klass = Class.new
  klass.send(:define_method, callback_method) do |model|
    model.history << [:"#{callback_method}_save", :object]
  end
  klass.new
end
callback_proc(callback_method) click to toggle source
# File activesupport/test/callbacks_test.rb, line 28
def callback_proc(callback_method)
  Proc.new { |model| model.history << [callback_method, :proc] }
end
callback_symbol(callback_method) click to toggle source
# File activesupport/test/callbacks_test.rb, line 20
def callback_symbol(callback_method)
  method_name = :"#{callback_method}_method"
  define_method(method_name) do
    history << [callback_method, :symbol]
  end
  method_name
end

Public Instance Methods

history() click to toggle source
# File activesupport/test/callbacks_test.rb, line 41
def history
  @history ||= []
end