class Mingo
Public Class Methods
new(obj = nil)
click to toggle source
Calls superclass method
Mingo::Changes::new
# File lib/mingo.rb, line 36 def initialize(obj = nil) super() if obj # a doc loaded straight from the db? if obj['_id'].is_a? BSON::ObjectId then merge!(obj) else obj.each { |prop, value| self.send("#{prop}=", value) } end end end
Public Instance Methods
==(other)
click to toggle source
# File lib/mingo.rb, line 55 def ==(other) other.is_a?(Mingo) && other.id == self.id end
cache_key()
click to toggle source
# File lib/mingo.rb, line 59 def cache_key model_key = self.class.model_name.cache_key if not persisted? "#{model_key}/new" elsif timestamp = self['updated_at'] "#{model_key}/#{id}-#{timestamp.utc.strftime("%Y%m%d%H%M%S")}" else "#{model_key}/#{id}" end end
id()
click to toggle source
# File lib/mingo.rb, line 51 def id self['_id'] end