Class: HatiJsonapiError::Resolver
- Inherits:
-
Object
- Object
- HatiJsonapiError::Resolver
- Defined in:
- lib/hati_jsonapi_error/resolver.rb
Overview
This class is used to resolve errors and serialize them to a JSON API format.
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#serializer ⇒ Object
readonly
Returns the value of attribute serializer.
Instance Method Summary collapse
-
#initialize(api_error, serializer: PoroSerializer) ⇒ Resolver
constructor
A new instance of Resolver.
- #status ⇒ Object
- #to_json(*_args) ⇒ Object
Constructor Details
#initialize(api_error, serializer: PoroSerializer) ⇒ Resolver
Returns a new instance of Resolver.
8 9 10 11 |
# File 'lib/hati_jsonapi_error/resolver.rb', line 8 def initialize(api_error, serializer: PoroSerializer) @errors = error_arr(api_error) @serializer = serializer.new(errors) end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
6 7 8 |
# File 'lib/hati_jsonapi_error/resolver.rb', line 6 def errors @errors end |
#serializer ⇒ Object (readonly)
Returns the value of attribute serializer.
6 7 8 |
# File 'lib/hati_jsonapi_error/resolver.rb', line 6 def serializer @serializer end |
Instance Method Details
#status ⇒ Object
13 14 15 |
# File 'lib/hati_jsonapi_error/resolver.rb', line 13 def status errors.first.status end |
#to_json(*_args) ⇒ Object
17 18 19 |
# File 'lib/hati_jsonapi_error/resolver.rb', line 17 def to_json(*_args) serializer.serialize_to_json end |