Sha256: c3ccd3cd783c6619d78392596aa8decffe42c28c61425b71cd4a2ff6e542be30
Contents?: true
Size: 695 Bytes
Versions: 23
Compression:
Stored size: 695 Bytes
Contents
require 'ostruct' # Response data is data provided through the response body # but made accssible in the ruby world class LHC::Response::Data < OpenStruct def initialize(response) @response = response set_dynamic_accessor_methods super(as_json) end def as_json response.format.as_json(response) end def as_open_struct response.format.as_open_struct(response) end def [](key) @hash ||= as_json.with_indifferent_access @hash[key] end private attr_reader :response def set_dynamic_accessor_methods as_json.keys.each do |key| define_singleton_method key do |*args| as_open_struct.send key, *args end end end end
Version data entries
23 entries across 23 versions & 1 rubygems