Method: Mongoid::Indexable::ClassMethods#index_specification

Defined in:
lib/mongoid/indexable.rb

#index_specification(index_hash, index_name = nil) ⇒ Specification

Get an index specification for the provided key.

Examples:

Get the index specification.

Model.index_specification(name: 1)

Parameters:

  • index_hash (Hash)

    The index key/direction pair.

  • index_name (String) (defaults to: nil)

    The index name.

Returns:

  • (Specification)

    The found specification.



118
119
120
121
122
# File 'lib/mongoid/indexable.rb', line 118

def index_specification(index_hash, index_name = nil)
  index_specifications.detect do |spec|
    spec.superficial_match?(key: index_hash, name: index_name)
  end
end