Class: Klient::ResponseData
- Inherits:
-
Object
- Object
- Klient::ResponseData
- Defined in:
- lib/klient/response_data.rb
Instance Attribute Summary collapse
-
#original_response ⇒ Object
readonly
Returns the value of attribute original_response.
-
#parsed_body ⇒ Object
readonly
Returns the value of attribute parsed_body.
-
#parsed_headers ⇒ Object
readonly
Returns the value of attribute parsed_headers.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Instance Method Summary collapse
- #body ⇒ Object
- #headers ⇒ Object
-
#initialize(status_code, parsed_body) ⇒ ResponseData
constructor
A new instance of ResponseData.
-
#method_missing(mth, *args, &block) ⇒ Object
TODO: Bandaid.
- #ok? ⇒ Boolean
- #respond_to_missing?(mth, *args) ⇒ Boolean
Constructor Details
#initialize(status_code, parsed_body) ⇒ ResponseData
Returns a new instance of ResponseData.
13 14 15 16 |
# File 'lib/klient/response_data.rb', line 13 def initialize(status_code, parsed_body) @status_code = status_code @parsed_body = parsed_body.freeze end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(mth, *args, &block) ⇒ Object
TODO: Bandaid.
23 24 25 |
# File 'lib/klient/response_data.rb', line 23 def method_missing(mth, *args, &block) @parsed_body.send(mth, *args, &block) end |
Instance Attribute Details
#original_response ⇒ Object (readonly)
Returns the value of attribute original_response.
3 4 5 |
# File 'lib/klient/response_data.rb', line 3 def original_response @original_response end |
#parsed_body ⇒ Object (readonly)
Returns the value of attribute parsed_body.
3 4 5 |
# File 'lib/klient/response_data.rb', line 3 def parsed_body @parsed_body end |
#parsed_headers ⇒ Object (readonly)
Returns the value of attribute parsed_headers.
3 4 5 |
# File 'lib/klient/response_data.rb', line 3 def parsed_headers @parsed_headers end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
3 4 5 |
# File 'lib/klient/response_data.rb', line 3 def status_code @status_code end |
Instance Method Details
#body ⇒ Object
5 6 7 |
# File 'lib/klient/response_data.rb', line 5 def body nil end |
#headers ⇒ Object
9 10 11 |
# File 'lib/klient/response_data.rb', line 9 def headers nil end |
#ok? ⇒ Boolean
18 19 20 |
# File 'lib/klient/response_data.rb', line 18 def ok? (200..299).include?(status_code) end |
#respond_to_missing?(mth, *args) ⇒ Boolean
27 28 29 |
# File 'lib/klient/response_data.rb', line 27 def respond_to_missing?(mth, *args) mth.to_s =~ /http_(\d+)\?/ || @parsed_body.respond_to?(mth) || super end |