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
, :method.
- #permit(*keys) ⇒ Object
- #response_headers ⇒ Object
- #status_code ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(res) ⇒ Response
, :method
8 9 10 11 12 13 14 |
# File 'lib/cassette-rack/response.rb', line 8 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.
5 6 7 |
# File 'lib/cassette-rack/response.rb', line 5 def body @body end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
5 6 7 |
# File 'lib/cassette-rack/response.rb', line 5 def content @content end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
5 6 7 |
# File 'lib/cassette-rack/response.rb', line 5 def headers @headers end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
5 6 7 |
# File 'lib/cassette-rack/response.rb', line 5 def status @status end |
Instance Method Details
#permit(*keys) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/cassette-rack/response.rb', line 28 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
20 21 22 |
# File 'lib/cassette-rack/response.rb', line 20 def response_headers headers end |
#status_code ⇒ Object
16 17 18 |
# File 'lib/cassette-rack/response.rb', line 16 def status_code status end |
#success? ⇒ Boolean
24 25 26 |
# File 'lib/cassette-rack/response.rb', line 24 def success? @response.success? end |