Sha256: 213921937b75538e8d9129d26a1436512250d5b724bd7eff482ff059e5890f9c
Contents?: true
Size: 918 Bytes
Versions: 23
Compression:
Stored size: 918 Bytes
Contents
# frozen_string_literal: true # TODO: move to Praxis proper...it's not used here module Praxis class ConfigHash < BasicObject attr_reader :hash def self.from(hash = {}, &block) new(hash, &block) end def initialize(hash = {}, &block) @hash = hash @block = block end def to_hash instance_eval(&@block) @hash end def respond_to_missing?(_method_name, _include_private = false) true end def method_missing(name, value, *rest, &block) if (existing = @hash[name]) if block existing << [value, block] else existing << value rest.each do |v| existing << v end end else @hash[name] = if rest.any? [value] + rest else value end end end end end
Version data entries
23 entries across 23 versions & 1 rubygems