Class: Eluvia::ErrorSerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/eluvia/serializers/error_serializer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#errorObject (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_hObject



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