module Ohm::Callbacks

The following is an example usage of this plugin:

class Post < Ohm::Model
  include Ohm::Callbacks

protected
  def before_create
    # sanitize the decimal values here
  end

  def before_save
    # do something here
  end

  def after_create
    # do twitter posting here
  end

  def after_save
    # do something with the ids
  end
end

Public Instance Methods

delete() click to toggle source
Calls superclass method
# File lib/ohm/callbacks.rb, line 41
def delete
  before_delete
  result = super
  after_delete

  return result
end
save() click to toggle source
Calls superclass method
# File lib/ohm/callbacks.rb, line 25
def save
  is_new = new?

  before_create if is_new
  before_update if not is_new
  before_save

  result = super

  after_create if is_new
  after_update if not is_new
  after_save

  return result
end

Protected Instance Methods

after_create() click to toggle source
# File lib/ohm/callbacks.rb, line 59
def after_create
end
after_delete() click to toggle source
# File lib/ohm/callbacks.rb, line 71
def after_delete
end
after_save() click to toggle source
# File lib/ohm/callbacks.rb, line 53
def after_save
end
after_update() click to toggle source
# File lib/ohm/callbacks.rb, line 65
def after_update
end
before_create() click to toggle source
# File lib/ohm/callbacks.rb, line 56
def before_create
end
before_delete() click to toggle source
# File lib/ohm/callbacks.rb, line 68
def before_delete
end
before_save() click to toggle source
# File lib/ohm/callbacks.rb, line 50
def before_save
end
before_update() click to toggle source
# File lib/ohm/callbacks.rb, line 62
def before_update
end