Sha256: 81dd7e4a86fcbdc9ee73fd1ec46302e8b6078540c442823d1eabb23d6b708008

Contents?: true

Size: 464 Bytes

Versions: 3

Compression:

Stored size: 464 Bytes

Contents

module Mongo
  module Voteable
    module Helpers

      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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rs_voteable_mongo-1.0.2 lib/voteable_mongo/helpers.rb
rs_voteable_mongo-1.0.1 lib/voteable_mongo/helpers.rb
rs_voteable_mongo-1.0.0 lib/voteable_mongo/helpers.rb