Sha256: af23d0c6c22835abbfd948bc6c46327f423deb07956f92b55887a2b15cbb4745

Contents?: true

Size: 449 Bytes

Versions: 9

Compression:

Stored size: 449 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
end

Version data entries

9 entries across 9 versions & 5 rubygems

Version Path
jonbell-mongo_mapper-0.8.6 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-0.9.0 lib/mongo_mapper/extensions/object_id.rb
ign-mongo_mapper-0.8.6.2 lib/mongo_mapper/extensions/object_id.rb
ign-mongo_mapper-0.8.6.1 lib/mongo_mapper/extensions/object_id.rb
ssherman-mongo_mapper-0.8.6 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-0.8.6 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-0.8.5 lib/mongo_mapper/extensions/object_id.rb
honkster-mongo_mapper-0.8.4 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-0.8.4 lib/mongo_mapper/extensions/object_id.rb