Class: Lighthouse::DirectDeposit::ErrorResponse
- Inherits:
-
Object
- Object
- Lighthouse::DirectDeposit::ErrorResponse
- Defined in:
- lib/lighthouse/direct_deposit/error_response.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #body ⇒ Object
- #code ⇒ Object
- #code=(code) ⇒ Object
- #detail ⇒ Object
- #error? ⇒ Boolean
-
#initialize(status, errors) ⇒ ErrorResponse
constructor
A new instance of ErrorResponse.
- #message ⇒ Object
- #response ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(status, errors) ⇒ ErrorResponse
Returns a new instance of ErrorResponse.
8 9 10 11 |
# File 'lib/lighthouse/direct_deposit/error_response.rb', line 8 def initialize(status, errors) @status = status @errors = errors || [] end |
Instance Attribute Details
#errors ⇒ Object
Returns the value of attribute errors.
6 7 8 |
# File 'lib/lighthouse/direct_deposit/error_response.rb', line 6 def errors @errors end |
#status ⇒ Object
Returns the value of attribute status.
6 7 8 |
# File 'lib/lighthouse/direct_deposit/error_response.rb', line 6 def status @status end |
Instance Method Details
#body ⇒ Object
20 21 22 |
# File 'lib/lighthouse/direct_deposit/error_response.rb', line 20 def body { errors: @errors } end |
#code ⇒ Object
28 29 30 |
# File 'lib/lighthouse/direct_deposit/error_response.rb', line 28 def code errors.first[:code] end |
#code=(code) ⇒ Object
24 25 26 |
# File 'lib/lighthouse/direct_deposit/error_response.rb', line 24 def code=(code) errors.first[:code] = code end |
#detail ⇒ Object
36 37 38 |
# File 'lib/lighthouse/direct_deposit/error_response.rb', line 36 def detail errors.first[:detail] end |
#error? ⇒ Boolean
44 45 46 |
# File 'lib/lighthouse/direct_deposit/error_response.rb', line 44 def error? true end |
#message ⇒ Object
40 41 42 |
# File 'lib/lighthouse/direct_deposit/error_response.rb', line 40 def "#{code}: #{title} - #{detail}" end |
#response ⇒ Object
13 14 15 16 17 18 |
# File 'lib/lighthouse/direct_deposit/error_response.rb', line 13 def response { status: @status, body: } end |
#title ⇒ Object
32 33 34 |
# File 'lib/lighthouse/direct_deposit/error_response.rb', line 32 def title errors.first[:title] end |