Class: JSONAPIHelpers::Serializers::Error
- Inherits:
-
Object
- Object
- JSONAPIHelpers::Serializers::Error
- Defined in:
- lib/jsonapi_helpers/serializers/error.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#detail ⇒ Object
readonly
Returns the value of attribute detail.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(detail:, status: 422, code: nil, pointer: nil, attribute: nil, key_transform: JSONAPIHelpers.config.key_transform) ⇒ Error
constructor
A new instance of Error.
- #to_h ⇒ Object
Constructor Details
#initialize(detail:, status: 422, code: nil, pointer: nil, attribute: nil, key_transform: JSONAPIHelpers.config.key_transform) ⇒ Error
Returns a new instance of Error.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/jsonapi_helpers/serializers/error.rb', line 8 def initialize( detail:, status: 422, code: nil, pointer: nil, attribute: nil, key_transform: JSONAPIHelpers.config.key_transform ) @status = status @detail = detail @pointer = pointer( pointer: pointer, attribute: attribute, key_transform: key_transform ) @code = code end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
6 7 8 |
# File 'lib/jsonapi_helpers/serializers/error.rb', line 6 def code @code end |
#detail ⇒ Object (readonly)
Returns the value of attribute detail.
6 7 8 |
# File 'lib/jsonapi_helpers/serializers/error.rb', line 6 def detail @detail end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/jsonapi_helpers/serializers/error.rb', line 6 def status @status end |
Instance Method Details
#to_h ⇒ Object
26 27 28 29 30 |
# File 'lib/jsonapi_helpers/serializers/error.rb', line 26 def to_h response = { status: @status, detail: @detail } response[:code] = @code unless @code.nil? response.merge!(@pointer) end |