Module: Mongo::Model::Misc

Defined in:
lib/mongo_db/model/misc.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#_cache ⇒ Object



9
10
11
# File 'lib/mongo_db/model/misc.rb', line 9

def _cache
  @_cache ||= {}
end

#_clear_cache ⇒ Object



12
13
14
# File 'lib/mongo_db/model/misc.rb', line 12

def _clear_cache
  @_cache = {}
end

#dom_id ⇒ Object



17
18
19
20
# File 'lib/mongo_db/model/misc.rb', line 17

def dom_id
  # new_record? ? "new_#{self.class.name.underscore}" : to_param
  to_param
end

#to_param ⇒ Object



22
23
24
# File 'lib/mongo_db/model/misc.rb', line 22

def to_param
  (_id || '').to_s
end

#update_timestamps ⇒ Object



2
3
4
5
6
# File 'lib/mongo_db/model/misc.rb', line 2

def update_timestamps
  now = Time.now.utc
  self.created_at ||= now
  self.updated_at = now
end