Class: Takeout::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/takeout/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Response

Returns a new instance of Response.



8
9
10
11
12
13
14
# File 'lib/takeout/response.rb', line 8

def initialize(options={})
  if block_given?
    yield self
  else
    extract_instance_variables_from_options(options)
  end
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



4
5
6
# File 'lib/takeout/response.rb', line 4

def body
  @body
end

#headersObject

Returns the value of attribute headers.



3
4
5
# File 'lib/takeout/response.rb', line 3

def headers
  @headers
end

#optionsObject

Returns the value of attribute options.



6
7
8
# File 'lib/takeout/response.rb', line 6

def options
  @options
end

#responseObject

Returns the value of attribute response.



5
6
7
# File 'lib/takeout/response.rb', line 5

def response
  @response
end

Instance Method Details

#extract_instance_variables_from_options(options) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/takeout/response.rb', line 16

def extract_instance_variables_from_options(options)
  # Set instance variables
  @headers = options[:headers] || ''
  @body = options[:body] || {}
  @response = options[:response] || {}


  # Clean instance variables out of options hash and set that as options instance variable
  [:headers, :body, :response].each { |v| options.delete(v) }
  @options = options
end