Sha256: 5d5cfabdd1bf8230dc623fc538604b2b7ab36e9078aa491cce87304a103beee3

Contents?: true

Size: 543 Bytes

Versions: 4

Compression:

Stored size: 543 Bytes

Contents

# encoding: UTF-8
module MongoMapper
  module Extensions
    module ObjectId
      def to_mongo(value)
        Plucky.to_object_id(value)
      end

      def from_mongo(value)
        value
      end
    end
  end
end

class ObjectId
  extend MongoMapper::Extensions::ObjectId
end

class BSON::ObjectId
  alias_method :original_as_json, :as_json

  def as_json(options=nil)
    to_s
  end

  def to_json(options = nil)
    as_json.to_json
  end

  alias to_str to_s

  def original_to_json(*args)
    original_as_json.to_json(*args)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mongo_mapper-0.15.3 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-0.15.2 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-0.15.1 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-0.15.0 lib/mongo_mapper/extensions/object_id.rb