Sha256: cabf483d16fa633a10778d4ad2815802dd7cafe98d6932f36bb4892023bf1b46

Contents?: true

Size: 449 Bytes

Versions: 52

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

52 entries across 52 versions & 3 rubygems

Version Path
mongo_mapper-unstable-2010.07.05 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-unstable-2010.07.02 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-unstable-2010.07.01 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-unstable-2010.06.30 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-unstable-2010.06.29 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-unstable-2010.06.28 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-unstable-2010.06.25 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-unstable-2010.06.24 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-unstable-2010.06.23 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-0.8.2 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-0.8.1 lib/mongo_mapper/extensions/object_id.rb
mongo_mapper-0.8.0 lib/mongo_mapper/extensions/object_id.rb