Module: Mongo::Voteable::Helpers
- Defined in:
- lib/voteable_mongo/helpers.rb
Class Method Summary collapse
Class Method Details
.get_mongo_id(x) ⇒ Object
13 14 15 |
# File 'lib/voteable_mongo/helpers.rb', line 13 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 8 9 10 11 |
# File 'lib/voteable_mongo/helpers.rb', line 5 def self.try_to_convert_string_to_object_id(x) if defined?(Moped::BSON) x.is_a?(String) && Moped::BSON::ObjectId.legal?(x) ? Moped::BSON::ObjectId.from_string(x) : x else x.is_a?(String) && BSON::ObjectId.legal?(x) ? BSON::ObjectId.from_string(x) : x end end |