Class: ObjectId

Inherits:
Object show all
Defined in:
lib/novelys_mongo_mapper/support.rb

Class Method Summary collapse

Class Method Details

.from_mongo(value) ⇒ Object



141
142
143
# File 'lib/novelys_mongo_mapper/support.rb', line 141

def self.from_mongo(value)
  value
end

.to_mongo(value) ⇒ Object



131
132
133
134
135
136
137
138
139
# File 'lib/novelys_mongo_mapper/support.rb', line 131

def self.to_mongo(value)
  if value.blank?
    nil
  elsif value.is_a?(Mongo::ObjectID)
    value
  else
    Mongo::ObjectID.from_string(value.to_s)
  end
end