Module: Mongo::Voteable::Helpers

Defined in:
lib/voteable_mongo/helpers.rb

Class Method Summary collapse

Class Method Details

.get_mongo_id(x) ⇒ Object



9
10
11
# File 'lib/voteable_mongo/helpers.rb', line 9

def self.get_mongo_id(x)
  x.respond_to?(:id) ? x.id : x
end

.try_to_convert_string_to_object_id(x) ⇒ Object



5
6
7
# File 'lib/voteable_mongo/helpers.rb', line 5

def self.try_to_convert_string_to_object_id(x)
  x.is_a?(String) && BSON::ObjectId.legal?(x) ? BSON::ObjectId.from_string(x) : x
end