Module: Mongoid::Indexable::Validators::Options
Relationships & Source Files | |
Defined in: | lib/mongoid/indexable/validators/options.rb |
Overview
Validates the options passed to the index macro.
Constant Summary
-
VALID_OPTIONS =
# File 'lib/mongoid/indexable/validators/options.rb', line 12[ :background, :database, :default_language, :language_override, :name, :sparse, :unique, :max, :min, :bits, :bucket_size, :expire_after_seconds, :weights, :storage_engine, :key, :sphere_version, :text_version, :version, :partial_filter_expression, :collation, :wildcard_projection, ]
-
VALID_TYPES =
# File 'lib/mongoid/indexable/validators/options.rb', line 36[ 1, -1, "2d", "2dsphere", "geoHaystack", "text", "hashed" ]
Instance Method Summary
-
#validate(klass, spec, options)
Validate the index specification.
-
#validate_options(klass, spec, options)
private
Internal use only
Internal use only
Validates the options of the index spec.
-
#validate_spec(klass, spec, options)
private
Internal use only
Internal use only
Validates the index spec.
Instance Method Details
#validate(klass, spec, options)
Validate the index specification.
# File 'lib/mongoid/indexable/validators/options.rb', line 56
def validate(klass, spec, ) validate_spec(klass, spec, ) (klass, spec, ) end
#validate_options(klass, spec, options) (private)
This method is for internal use only.
Validates the options of the index spec.
# File 'lib/mongoid/indexable/validators/options.rb', line 75
def (klass, spec, ) .each_pair do |name, value| unless VALID_OPTIONS.include?(name) raise Errors::InvalidIndex.new(klass, spec, ) end end end
#validate_spec(klass, spec, options) (private)
This method is for internal use only.
Validates the index spec.
# File 'lib/mongoid/indexable/validators/options.rb', line 95
def validate_spec(klass, spec, ) raise Errors::InvalidIndex.new(klass, spec, ) if !spec.is_a?(::Hash) spec.each_pair do |name, value| next if name == : unless VALID_TYPES.include?(value) raise Errors::InvalidIndex.new(klass, spec, ) end if value == "geoHaystack" Mongoid::Warnings.warn_geo_haystack_deprecated end end end