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 10%i[ 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 34[ 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 54
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 73
def (klass, spec, ) .each_pair do |name, _value| raise Errors::InvalidIndex.new(klass, spec, ) unless VALID_OPTIONS.include?(name) 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 91
def validate_spec(klass, spec, ) raise Errors::InvalidIndex.new(klass, spec, ) unless spec.is_a?(::Hash) spec.each_pair do |name, value| next if name == : raise Errors::InvalidIndex.new(klass, spec, ) unless VALID_TYPES.include?(value) Mongoid::Warnings.warn_geo_haystack_deprecated if value == 'geoHaystack' end end