Class: DHS::Problems::Errors
Direct Known Subclasses
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Attributes inherited from Base
#codes, #messages, #raw, #record
Instance Method Summary collapse
-
#initialize(response = nil, record = nil) ⇒ Errors
constructor
A new instance of Errors.
Methods inherited from Base
#[], #[]=, #add, #clear, #count, #each, #empty?, #get, #include?, #set, #size
Constructor Details
#initialize(response = nil, record = nil) ⇒ Errors
Returns a new instance of Errors.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/dhs/problems/errors.rb', line 8 def initialize(response = nil, record = nil) @raw = response.body if response @record = record @codes = {}.with_indifferent_access @messages = (response).with_indifferent_access @message = (response) @status_code = response.code if response rescue JSON::ParserError @messages = ( || {}).with_indifferent_access @codes = (codes || {}).with_indifferent_access @message = 'parse error' add_error(@messages, 'body', 'parse error') end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
6 7 8 |
# File 'lib/dhs/problems/errors.rb', line 6 def @message end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
6 7 8 |
# File 'lib/dhs/problems/errors.rb', line 6 def status_code @status_code end |