Exception: TypedCache::TypeError

Inherits:
Error
  • Object
show all
Defined in:
lib/typed_cache/errors.rb

Overview

Type safety violations

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expected_type, actual_type, value, message) ⇒ TypeError

Returns a new instance of TypeError.



44
45
46
47
48
49
# File 'lib/typed_cache/errors.rb', line 44

def initialize(expected_type, actual_type, value, message)
  super(message)
  @expected_type = expected_type
  @actual_type = actual_type
  @value = value
end

Instance Attribute Details

#actual_typeObject (readonly)

Returns the value of attribute actual_type.



41
42
43
# File 'lib/typed_cache/errors.rb', line 41

def actual_type
  @actual_type
end

#expected_typeObject (readonly)

Returns the value of attribute expected_type.



41
42
43
# File 'lib/typed_cache/errors.rb', line 41

def expected_type
  @expected_type
end

#valueObject (readonly)

Returns the value of attribute value.



41
42
43
# File 'lib/typed_cache/errors.rb', line 41

def value
  @value
end

Instance Method Details

#type_mismatch_messageObject



52
53
54
# File 'lib/typed_cache/errors.rb', line 52

def type_mismatch_message
  "Expected #{expected_type}, got #{actual_type}"
end