module Mongoid::Indexable::Validators::Options
def validate(klass, spec, options)
- Since: - 3.0.0
Raises:
-
(Errors::InvalidIndex)- If validation failed.
Parameters:
-
options(Hash) -- The index options. -
spec(Hash) -- The index specification. -
klass(Class) -- The model class.
Other tags:
- Example: Validate the index spec. -
def validate(klass, spec, options) validate_spec(klass, spec, options) validate_options(klass, spec, options) end
def validate_options(klass, spec, options)
- Since: - 3.0.0
Raises:
-
(Errors::InvalidIndex)- If validation failed.
Parameters:
-
options(Hash) -- The index options. -
spec(Hash) -- The index specification. -
klass(Class) -- The model class.
Other tags:
- Example: Validate the options. -
Other tags:
- Api: - private
def validate_options(klass, spec, options) options.each_pair do |name, value| unless VALID_OPTIONS.include?(name) raise Errors::InvalidIndex.new(klass, spec, options) end end end
def validate_spec(klass, spec, options)
- Since: - 3.0.0
Raises:
-
(Errors::InvalidIndex)- If validation failed.
Parameters:
-
options(Hash) -- The index options. -
spec(Hash) -- The index specification. -
klass(Class) -- The model class.
Other tags:
- Example: Validate the spec. -
Other tags:
- Api: - private
def validate_spec(klass, spec, options) raise Errors::InvalidIndex.new(klass, spec, options) if !spec.is_a?(::Hash) spec.each_pair do |name, value| next if name == :options unless VALID_TYPES.include?(value) raise Errors::InvalidIndex.new(klass, spec, options) end end end