Exception: SafeType::CoercionError
- Inherits:
-
StandardError
- Object
- StandardError
- SafeType::CoercionError
- Defined in:
- lib/safe_type/errors.rb
Instance Attribute Summary collapse
-
#desired_type ⇒ Object
readonly
Returns the value of attribute desired_type.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(value, desired_type, key = nil) ⇒ CoercionError
constructor
A new instance of CoercionError.
Constructor Details
#initialize(value, desired_type, key = nil) ⇒ CoercionError
Returns a new instance of CoercionError.
8 9 10 11 12 13 14 15 |
# File 'lib/safe_type/errors.rb', line 8 def initialize(value, desired_type, key=nil) super("Could not coerce " + (key.nil? ? '' : "key (#{key}) with ") + "value (#{value.inspect}) of type (#{value.class}) to desired type (#{desired_type})") @key = key @value = value @desired_type = desired_type end |
Instance Attribute Details
#desired_type ⇒ Object (readonly)
Returns the value of attribute desired_type.
6 7 8 |
# File 'lib/safe_type/errors.rb', line 6 def desired_type @desired_type end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
4 5 6 |
# File 'lib/safe_type/errors.rb', line 4 def key @key end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
5 6 7 |
# File 'lib/safe_type/errors.rb', line 5 def value @value end |