Exception: Mongoid::Errors::InvalidType

Inherits:
MongoidError show all
Defined in:
lib/mongoid/errors/invalid_type.rb

Overview

Raised when trying to get or set a value for a defined field, where the type of the object does not match the defined field type.

Example:

InvalidType.new(Array, "Not an Array")

Constant Summary

Constants inherited from MongoidError

MongoidError::BASE_KEY

Instance Method Summary collapse

Methods inherited from MongoidError

#translate

Constructor Details

#initialize(klass, value) ⇒ InvalidType

Returns a new instance of InvalidType.



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/mongoid/errors/invalid_type.rb', line 12

def initialize(klass, value)
  super(
    translate(
      "invalid_type",
      {
        :klass => klass.name,
        :other => value.class.name,
        :value => value.inspect
      }
    )
  )
end