lib/mongo_mapper/support.rb in tpitale-mongo_mapper-0.6.9 vs lib/mongo_mapper/support.rb in tpitale-mongo_mapper-0.6.10
- old
+ new
@@ -118,11 +118,11 @@
end
end
class ObjectId
def self.to_mongo(value)
- if value.nil?
+ if value.blank?
nil
elsif value.is_a?(Mongo::ObjectID)
value
else
Mongo::ObjectID.from_string(value.to_s)
@@ -175,12 +175,15 @@
define_method operator do
DataMapper::Query::Operator.new(self, operator.to_sym)
end
end
end
+
+ def asc; MongoMapper::OrderOperator.new(self, 'asc') end
+ def desc; MongoMapper::OrderOperator.new(self, 'desc') end
end
-class Time
+class Time
def self.to_mongo(value)
if value.nil? || value == ''
nil
else
time = MongoMapper.time_class.parse(value.to_s)
\ No newline at end of file