Class: Sawyer::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/looker-sdk/sawyer_patch.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(agent, res, options = {}) ⇒ Response

Returns a new instance of Response.



10
11
12
13
14
15
16
17
18
19
# File 'lib/looker-sdk/sawyer_patch.rb', line 10

def initialize(agent, res, options = {})
  @agent   = agent
  @status  = res.status
  @headers = res.headers
  @env     = res.env
  @body    = res.body
  @rels    = process_rels
  @started = options[:sawyer_started]
  @ended   = options[:sawyer_ended]
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



8
9
10
# File 'lib/looker-sdk/sawyer_patch.rb', line 8

def body
  @body
end

#envObject (readonly)

Returns the value of attribute env.



8
9
10
# File 'lib/looker-sdk/sawyer_patch.rb', line 8

def env
  @env
end

Instance Method Details

#dataObject



21
22
23
24
25
26
# File 'lib/looker-sdk/sawyer_patch.rb', line 21

def data
  @data ||= begin
    return(body) unless (headers[:content_type] =~ /json|msgpack/)
    process_data(agent.decode_body(body))
  end
end

#inspectObject



28
29
30
# File 'lib/looker-sdk/sawyer_patch.rb', line 28

def inspect
  %(#<#{self.class}: #{@status} @rels=#{@rels.inspect} @data=#{data.inspect}>)
end