Sha256: c6b744d1f6b0c0bdce7188db91cb3cc8b89ca3c8224dcf1c57ed4c480ef0a8d2
Contents?: true
Size: 417 Bytes
Versions: 10
Compression:
Stored size: 417 Bytes
Contents
# frozen_string_literal: true class HttpJsonModel attr_reader :json class << self def parse(attribute, path: []) keys = (path + [attribute]).map(&:to_s) Sinclair.build(self) do add_method(attribute) do keys.inject(hash) { |h, key| h[key] } end end end end def initialize(json) @json = json end def hash @hash ||= JSON.parse(json) end end
Version data entries
10 entries across 10 versions & 1 rubygems