Exception: Virtus::CoercionError
- Inherits:
-
StandardError
- Object
- StandardError
- Virtus::CoercionError
- Defined in:
- lib/virtus.rb
Instance Attribute Summary collapse
- #attribute ⇒ Object readonly
- #output ⇒ Object readonly
Instance Method Summary collapse
- #attribute_name ⇒ Object
- #attribute_name? ⇒ Boolean
- #build_message ⇒ Object
-
#initialize(output, attribute) ⇒ CoercionError
constructor
A new instance of CoercionError.
- #target_type ⇒ Object
Constructor Details
#initialize(output, attribute) ⇒ CoercionError
Returns a new instance of CoercionError.
16 17 18 19 |
# File 'lib/virtus.rb', line 16 def initialize(output, attribute) @output, @attribute = output, attribute super() end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
14 15 16 |
# File 'lib/virtus.rb', line 14 def attribute @attribute end |
#output ⇒ Object (readonly)
14 15 16 |
# File 'lib/virtus.rb', line 14 def output @output end |
Instance Method Details
#attribute_name ⇒ Object
29 30 31 |
# File 'lib/virtus.rb', line 29 def attribute_name attribute.[:name] end |
#attribute_name? ⇒ Boolean
33 34 35 |
# File 'lib/virtus.rb', line 33 def attribute_name? attribute_name ? true : false end |
#build_message ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/virtus.rb', line 21 def if attribute_name? "Failed to coerce attribute `#{attribute_name}' from #{output.inspect} into #{target_type}" else "Failed to coerce #{output.inspect} into #{target_type}" end end |
#target_type ⇒ Object
37 38 39 |
# File 'lib/virtus.rb', line 37 def target_type attribute.primitive.inspect end |