Sha256: a807fd9c2ff205b320656f9e560c53578739ee55980248670d733335b2338dc1

Contents?: true

Size: 470 Bytes

Versions: 16

Compression:

Stored size: 470 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_to_json, :to_json

  def as_json(options=nil)
    to_s
  end

  def to_json(options = nil)
    as_json.to_json
  end

  alias to_str to_s
end

Version data entries

16 entries across 16 versions & 3 rubygems

Version Path
mongo_mapper-0.14.0 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-0.14.0.rc1 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-0.13.1 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-0.13.0 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-0.13.0.beta2 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-0.13.0.beta1 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-0.12.0 lib/mongo_mapper/extensions/object_id.rb
lookout-mongo_mapper-0.11.3 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-0.11.2 lib/mongo_mapper/extensions/object_id.rb
jamieorc-mongo_mapper-0.11.1.1 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-0.11.1 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-0.11.0 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-0.10.1 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-0.10.0 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-0.9.2 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-0.9.1 lib/mongo_mapper/extensions/object_id.rb