Module: Mongoid::Indexable::Validators::Options

Extended by:
Options
Included in:
Options
Defined in:
lib/mongoid/indexable/validators/options.rb

Overview

Validates the options passed to the index macro.

Since:

  • 4.0.0

Constant Summary collapse

VALID_OPTIONS =

Since:

  • 4.0.0

[
  :background,
  :database,
  :default_language,
  :drop_dups,
  :name,
  :sparse,
  :unique,
  :max,
  :min,
  :bits,
  :bucket_size,
  :expire_after_seconds,
  :weights
]
VALID_TYPES =

Since:

  • 4.0.0

[
  1,
  -1,
  "2d",
  "2dsphere",
  "geoHaystack",
  "text",
  "hashed"
]

Instance Method Summary collapse

Instance Method Details

#validate(klass, spec, options) ⇒ Object

Validate the index specification.

Examples:

Validate the index spec.

Options.validate(Band, name: 1)

Parameters:

  • klass (Class)

    The model class.

  • spec (Hash)

    The index specification.

  • options (Hash)

    The index options.

Raises:

Since:

  • 3.0.0


48
49
50
51
# File 'lib/mongoid/indexable/validators/options.rb', line 48

def validate(klass, spec, options)
  validate_spec(klass, spec, options)
  validate_options(klass, spec, options)
end