Class: Incentivale::Response

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

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



3
4
5
6
7
8
9
10
11
# File 'lib/incentivale/response.rb', line 3

def initialize(response)
  @response = response
  if json.is_a?(Hash)
    super(RecursiveOpenStruct.new(json, recurse_over_arrays: true))
  else
    super(@response.body)
  end
  @response
end

Instance Method Details

#jsonObject



13
14
15
# File 'lib/incentivale/response.rb', line 13

def json
  @json ||= JSON.parse(@response.body).to_snake_keys
end