Exception: Mongoid::Errors::InvalidFieldOption

Inherits:
MongoidError
  • Object
show all
Defined in:
build/mongoid-7.3/lib/mongoid/errors/invalid_field_option.rb

Overview

This error is raised when trying to create a field that has an invalid option.

Constant Summary

Constants inherited from MongoidError

MongoidError::BASE_KEY

Instance Attribute Summary

Attributes inherited from MongoidError

#problem, #resolution, #summary

Instance Method Summary collapse

Methods inherited from MongoidError

#compose_message

Constructor Details

#initialize(klass, name, option, valid) ⇒ InvalidFieldOption

Create the new error.

Examples:

Create the error.

InvalidFieldOption.new(Model, :name, :localized, [ :localize ])

Parameters:

  • klass (Class)

    The document class.

  • name (Symbol)

    The method name.

  • option (Symbol)

    The option name.

  • valid (Array<Symbol>)

    All the valid options.

Since:

  • 3.0.0



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'build/mongoid-7.3/lib/mongoid/errors/invalid_field_option.rb', line 22

def initialize(klass, name, option, valid)
  super(
    compose_message(
      "invalid_field_option",
      {
        name: name,
        klass: klass,
        option: option,
        valid: valid.join(", ")
      }
    )
  )
end