Sha256: 801cd6bac9e8a6b082ce42f7453546082cacf84e1be8c1734b801c7f5107282d

Contents?: true

Size: 485 Bytes

Versions: 29

Compression:

Stored size: 485 Bytes

Contents

# frozen_string_literal: true

# Response data is data provided through the response body
# but made accssible in the ruby world
module LHC::Response::Data::Base
  def as_json
    @json ||= (@data || response.format.as_json(response.body))
  end

  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

  private

  attr_reader :response
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
lhc-12.1.1 lib/lhc/response/data/base.rb
lhc-12.1.0 lib/lhc/response/data/base.rb
lhc-12.0.3 lib/lhc/response/data/base.rb
lhc-12.0.2 lib/lhc/response/data/base.rb
lhc-12.0.1 lib/lhc/response/data/base.rb
lhc-12.0.0 lib/lhc/response/data/base.rb
lhc-11.2.0 lib/lhc/response/data/base.rb
lhc-11.1.1 lib/lhc/response/data/base.rb
lhc-11.1.0 lib/lhc/response/data/base.rb
lhc-11.0.2 lib/lhc/response/data/base.rb
lhc-11.0.1 lib/lhc/response/data/base.rb
lhc-11.0.0 lib/lhc/response/data/base.rb
lhc-10.5.4 lib/lhc/response/data/base.rb
lhc-10.5.3 lib/lhc/response/data/base.rb
lhc-10.5.2 lib/lhc/response/data/base.rb
lhc-10.5.1 lib/lhc/response/data/base.rb
lhc-10.5.0 lib/lhc/response/data/base.rb
lhc-10.4.3 lib/lhc/response/data/base.rb
lhc-10.4.2 lib/lhc/response/data/base.rb
lhc-10.4.1 lib/lhc/response/data/base.rb