Class: CassetteRack::Decorator::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/cassette-rack/decorator/response.rb

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



6
7
8
# File 'lib/cassette-rack/decorator/response.rb', line 6

def initialize(response)
  @response = response
end

Instance Method Details

#bodyObject



26
27
28
29
30
# File 'lib/cassette-rack/decorator/response.rb', line 26

def body
  JSON.pretty_generate JSON.parse(@response.body)
rescue
  @response.body
end

#status_codeObject



18
19
20
# File 'lib/cassette-rack/decorator/response.rb', line 18

def status_code
  @response.status.code
end

#status_messageObject



22
23
24
# File 'lib/cassette-rack/decorator/response.rb', line 22

def status_message
  @response.status.message
end

#to_liquidObject



10
11
12
13
14
15
16
# File 'lib/cassette-rack/decorator/response.rb', line 10

def to_liquid
  {
    'status_code' => status_code,
    'status_message' => status_message,
    'body' => body,
  }
end