Exception: ValidArray::TypedArray::UnexpectedTypeException

Inherits:
Exception
  • Object
show all
Defined in:
lib/valid_array/typed_array.rb

Overview

The exception that is raised when an Unexpected Type is reached during validation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expected_one_of, received) ⇒ UnexpectedTypeException

Returns a new instance of UnexpectedTypeException.



36
37
38
39
# File 'lib/valid_array/typed_array.rb', line 36

def initialize(expected_one_of, received)
  @expected = expected_one_of
  @received = received
end

Instance Attribute Details

#expectedObject (readonly)

Provide access to the types of objects expected and the class of the object received



34
35
36
# File 'lib/valid_array/typed_array.rb', line 34

def expected
  @expected
end

#receivedObject (readonly)

Provide access to the types of objects expected and the class of the object received



34
35
36
# File 'lib/valid_array/typed_array.rb', line 34

def received
  @received
end

Instance Method Details

#to_sObject



41
42
43
# File 'lib/valid_array/typed_array.rb', line 41

def to_s
  %{Expected one of #{@expected.inspect} but received a(n) #{@received}}
end