Exception: Eddy::Errors::TypeValidationError
- Inherits:
-
ElementValidationError
- Object
- StandardError
- Error
- ElementValidationError
- Eddy::Errors::TypeValidationError
- Defined in:
- lib/eddy/errors.rb
Overview
Exception raised when an invalid argument is passed to the value=
method of an Models::Element::Base class.
Instance Attribute Summary
Attributes inherited from ElementValidationError
Element Validation Errors collapse
Methods inherited from ElementValidationError
Constructor Details
#initialize(msg = "", element:, arg:) ⇒ void
73 74 75 76 77 78 79 80 |
# File 'lib/eddy/errors.rb', line 73 def initialize(msg = "", element:, arg:) self.element = element self.arg = arg if msg.length == 0 msg << "Value must to be a #{wanted_type(element)}; recieved #{self.arg} (#{self.arg.class.name})" end super(msg) end |
Instance Method Details
#wanted_type(el) ⇒ String
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/eddy/errors.rb', line 84 def wanted_type(el) return case el when Eddy::Models::Element::AN then "String" when Eddy::Models::Element::B then "String" when Eddy::Models::Element::DT then "Time" when Eddy::Models::Element::TM then "Time" when Eddy::Models::Element::N then "Float or Integer" when Eddy::Models::Element::R then "Float or Integer" end end |