Class: Mongoid::Enum::InvalidKey

Inherits:
Object
  • Object
show all
Defined in:
lib/mongoid/enum/invalid_key.rb

Overview

Internal: Wraps invalid keys passed to setter so that getter returns the same key.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ InvalidKey

Returns a new instance of InvalidKey.



11
12
13
# File 'lib/mongoid/enum/invalid_key.rb', line 11

def initialize(key)
  @original_key = key
end

Instance Attribute Details

#original_keyObject (readonly)

:nodoc:



9
10
11
# File 'lib/mongoid/enum/invalid_key.rb', line 9

def original_key
  @original_key
end

Instance Method Details

#raise_errorObject Also known as: bson_type, to_bson



15
16
17
# File 'lib/mongoid/enum/invalid_key.rb', line 15

def raise_error
  fail InvalidKeyError, "invalid enum key: #{original_key}"
end