Class: Smplkit::ApiErrorDetail
- Inherits:
-
Object
- Object
- Smplkit::ApiErrorDetail
- Defined in:
- lib/smplkit/errors.rb
Overview
A single error object from the server’s JSON:API errors array.
Instance Attribute Summary collapse
-
#detail ⇒ Object
readonly
Returns the value of attribute detail.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(status: nil, title: nil, detail: nil, source: nil) ⇒ ApiErrorDetail
constructor
A new instance of ApiErrorDetail.
- #to_h ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(status: nil, title: nil, detail: nil, source: nil) ⇒ ApiErrorDetail
Returns a new instance of ApiErrorDetail.
10 11 12 13 14 15 |
# File 'lib/smplkit/errors.rb', line 10 def initialize(status: nil, title: nil, detail: nil, source: nil) @status = status @title = title @detail = detail @source = source || {} end |
Instance Attribute Details
#detail ⇒ Object (readonly)
Returns the value of attribute detail.
8 9 10 |
# File 'lib/smplkit/errors.rb', line 8 def detail @detail end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
8 9 10 |
# File 'lib/smplkit/errors.rb', line 8 def source @source end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
8 9 10 |
# File 'lib/smplkit/errors.rb', line 8 def status @status end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
8 9 10 |
# File 'lib/smplkit/errors.rb', line 8 def title @title end |
Instance Method Details
#to_h ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/smplkit/errors.rb', line 17 def to_h h = {} h["status"] = @status unless @status.nil? h["title"] = @title unless @title.nil? h["detail"] = @detail unless @detail.nil? h["source"] = @source unless @source.empty? h end |
#to_json ⇒ Object
26 27 28 |
# File 'lib/smplkit/errors.rb', line 26 def to_json(*) JSON.generate(to_h, *) end |