Sha256: fa25374362a535343bdff127fa01f6e36f2cbed2c7833dc1c2fe6934deb80ff5
Contents?: true
Size: 623 Bytes
Versions: 12
Compression:
Stored size: 623 Bytes
Contents
# frozen_string_literal: true require "date" module Seam class DeepHashAccessor def initialize(data) @data = data create_accessor_methods end def [](key) instance_variable_get(:"@#{key}") end private def create_accessor_methods @data.each do |key, value| define_singleton_method(key) do process_value(value) end end end def process_value(value) case value when Hash DeepHashAccessor.new(value) when Array value.map { |v| process_value(v) } else value end end end end
Version data entries
12 entries across 12 versions & 1 rubygems