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.



34
35
36
37
38
39
40
41
42
43
# File 'lib/looker-sdk/sawyer_patch.rb', line 34

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.



32
33
34
# File 'lib/looker-sdk/sawyer_patch.rb', line 32

def body
  @body
end

#envObject (readonly)

Returns the value of attribute env.



32
33
34
# File 'lib/looker-sdk/sawyer_patch.rb', line 32

def env
  @env
end

Instance Method Details

#dataObject



45
46
47
48
49
50
# File 'lib/looker-sdk/sawyer_patch.rb', line 45

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

#inspectObject



52
53
54
# File 'lib/looker-sdk/sawyer_patch.rb', line 52

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