Sha256: d6fd679186daf92fbb86b7281679d276fcf39764705378001ec859ebc0a057a7

Contents?: true

Size: 544 Bytes

Versions: 5

Compression:

Stored size: 544 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

5 entries across 5 versions & 1 rubygems

Version Path
mongo_mapper-0.17.0 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-0.16.0 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-0.15.6 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-0.15.5 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-0.15.4 lib/mongo_mapper/extensions/object_id.rb