Skip to content

Instantly share code, notes, and snippets.

@saks
Created August 11, 2010 08:19
Show Gist options
  • Save saks/518678 to your computer and use it in GitHub Desktop.
Save saks/518678 to your computer and use it in GitHub Desktop.
require 'mongoid'
Mongoid.configure do |config|
name = "control_development"
host = "localhost"
config.master = Mongo::Connection.new.db(name)
config.persist_in_safe_mode = false
end
class Site
include Mongoid::Document
field :name
def name=(new_name)
audit 'while object building'
end
def audit(message)
puts [message,
"\tnew_record?: #{self.new_record?}",
"\tinstance_variables: #{self.instance_variables}",
"\t@new_record defined?: #{self.instance_variable_defined? :@new_record}",
]
end
end
site = Site.new :name => 'new name'
site.audit 'after object building'
site = Site.instantiate("_id" => "1")
site.audit 'after instantiate'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment