Class: JsonapiErrorsHandler::ErrorSerializer

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

Overview

Serializes the given error to match the JSON:API specification

Instance Method Summary collapse

Constructor Details

#initialize(error) ⇒ ErrorSerializer

Returns a new instance of ErrorSerializer.



9
10
11
# File 'lib/jsonapi_errors_handler/error_serializer.rb', line 9

def initialize(error)
  @error = error
end

Instance Method Details

#to_hObject



13
14
15
# File 'lib/jsonapi_errors_handler/error_serializer.rb', line 13

def to_h
  serializable_hash
end

#to_json(_payload = nil) ⇒ Object



17
18
19
# File 'lib/jsonapi_errors_handler/error_serializer.rb', line 17

def to_json(_payload = nil)
  to_h.to_json
end