Module: LHC::Response::Data::Base

Included in:
LHC::Response::Data, Collection, Item
Defined in:
lib/lhc/response/data/base.rb

Overview

Response data is data provided through the response body but made accssible in the ruby world

Instance Method Summary collapse

Instance Method Details

#as_jsonObject



6
7
8
# File 'lib/lhc/response/data/base.rb', line 6

def as_json
  @json ||= (@data || @response.format.as_json(@response.body))
end

#as_open_structObject



10
11
12
13
14
15
16
17
# File 'lib/lhc/response/data/base.rb', line 10

def as_open_struct
  @open_struct ||=
    if @data
      JSON.parse(@data.to_json, object_class: OpenStruct)
    else
      @response.format.as_open_struct(@response.body)
    end
end