Sha256: f5c5bac82c48f75ccf84a0a1a78fb19c880c90aed9c6cde644d94417ffb5b426
Contents?: true
Size: 810 Bytes
Versions: 1
Compression:
Stored size: 810 Bytes
Contents
require 'nested_config/version' class NestedConfig autoload :EvaluateOnce, 'nested_config/evaluate_once' def initialize @hash = {} end def [](name, *args) @hash[name.to_s] end def []=(name, value) @hash[name.to_s] = value end def __hash__ @hash end def __with_cloned__ backup = Marshal.load(Marshal.dump(@hash)) yield(self) ensure @hash = backup end def inspect @hash end def method_missing(name, *args) if block_given? config = self[name] ||= self.class.new yield config else key = name.to_s.gsub(/=$/, '') if $& == '=' self[key] = args.first else self[key, *args] end end end def respond_to?(name, include_private=false) __hash__.key?(name.to_s) || super end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nested_config-0.4.0 | lib/nested_config.rb |