Created
August 11, 2010 08:19
-
-
Save saks/518678 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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