Class: Eluvia::ErrorSerializer
- Defined in:
- lib/eluvia/serializers/error_serializer.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
Instance Method Summary collapse
-
#initialize(error) ⇒ ErrorSerializer
constructor
A new instance of ErrorSerializer.
- #to_h ⇒ Object
- #to_json(_payload) ⇒ Object
Constructor Details
#initialize(error) ⇒ ErrorSerializer
Returns a new instance of ErrorSerializer.
6 7 8 |
# File 'lib/eluvia/serializers/error_serializer.rb', line 6 def initialize(error) @error = error end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
4 5 6 |
# File 'lib/eluvia/serializers/error_serializer.rb', line 4 def error @error end |
Instance Method Details
#to_h ⇒ Object
10 11 12 13 14 |
# File 'lib/eluvia/serializers/error_serializer.rb', line 10 def to_h { errors: Array.wrap(error.to_h).flatten } end |
#to_json(_payload) ⇒ Object
16 17 18 |
# File 'lib/eluvia/serializers/error_serializer.rb', line 16 def to_json(_payload) to_h.to_json end |