Class: AnswerLayer::ApiResponse
- Inherits:
-
Object
- Object
- AnswerLayer::ApiResponse
- Defined in:
- lib/answerlayer/responses/api_response.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(data = {}, status: nil, headers: {}) ⇒ ApiResponse
constructor
A new instance of ApiResponse.
- #to_h ⇒ Object
Constructor Details
#initialize(data = {}, status: nil, headers: {}) ⇒ ApiResponse
Returns a new instance of ApiResponse.
7 8 9 10 11 |
# File 'lib/answerlayer/responses/api_response.rb', line 7 def initialize(data = {}, status: nil, headers: {}) @data = data @status = status @headers = headers end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/answerlayer/responses/api_response.rb', line 5 def data @data end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
5 6 7 |
# File 'lib/answerlayer/responses/api_response.rb', line 5 def headers @headers end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
5 6 7 |
# File 'lib/answerlayer/responses/api_response.rb', line 5 def status @status end |
Instance Method Details
#[](key) ⇒ Object
13 14 15 |
# File 'lib/answerlayer/responses/api_response.rb', line 13 def [](key) data[key.to_s] || data[key.to_sym] end |
#to_h ⇒ Object
17 18 19 |
# File 'lib/answerlayer/responses/api_response.rb', line 17 def to_h data end |