Sha256: bc710409d0d8ad23081b87bd664e3852d99e1262babe7bc929ae5fd906e735b0

Contents?: true

Size: 412 Bytes

Versions: 1

Compression:

Stored size: 412 Bytes

Contents

require 'mongoid'

Mongoid::Identity.module_eval do
protected
  class << self
    # Return the proper id for the document.
    def generate_id
      if Mongoid.master.pk_factory
        id_hash = Mongoid.master.pk_factory.create_pk({})
        id = id_hash['_id'] || id_hash[:_id]
      else
        id = Mongo::ObjectID.new
      end
      Mongoid.use_object_ids ? id : id.to_s
    end
  end # class << self
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongoid_pk_factory-1.0.0 lib/mongoid_pk_factory.rb