Mongo Mapper

Callbacks

MongoMapper makes use of the ActiveModel::Callbacks, so they are identical to Rails.

The callbacks supported are the same as on ActiveModel, the callbacks provided are:

For embedded documents you have similar callbacks:

Example

The callbacks are set on your model like this:

class Monkey
  include MongoMapper::Document
  before_save :do_something_before_save

  private
  def do_something_before_save
  end
end
Fork me on GitHub