Class: CassetteRack::Response
- Inherits:
-
Object
- Object
- CassetteRack::Response
- Defined in:
- lib/cassette-rack/response.rb,
lib/cassette-rack/response/raise_error.rb
Defined Under Namespace
Classes: Error, RaiseError
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(res) ⇒ Response
constructor
A new instance of Response.
- #permit(*keys) ⇒ Object
- #response_headers ⇒ Object
- #status_code ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(res) ⇒ Response
Returns a new instance of Response.
5 6 7 8 9 10 11 |
# File 'lib/cassette-rack/response.rb', line 5 def initialize(res) @response = res @status = res.status @headers = res.headers @body = res.body parse_content end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
3 4 5 |
# File 'lib/cassette-rack/response.rb', line 3 def body @body end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
3 4 5 |
# File 'lib/cassette-rack/response.rb', line 3 def content @content end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
3 4 5 |
# File 'lib/cassette-rack/response.rb', line 3 def headers @headers end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
3 4 5 |
# File 'lib/cassette-rack/response.rb', line 3 def status @status end |
Instance Method Details
#permit(*keys) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/cassette-rack/response.rb', line 25 def permit(*keys) case content when Hash content.select { |key| keys.include? key } when Array content.map { |item| item.select { |key| keys.include? key } } end end |
#response_headers ⇒ Object
17 18 19 |
# File 'lib/cassette-rack/response.rb', line 17 def response_headers headers end |
#status_code ⇒ Object
13 14 15 |
# File 'lib/cassette-rack/response.rb', line 13 def status_code status end |
#success? ⇒ Boolean
21 22 23 |
# File 'lib/cassette-rack/response.rb', line 21 def success? @response.success? end |