Sha256: 103f2bb4773e75e3f914316f48ab8ce65bceb765559545bd6737e6a0ce376e28
Contents?: true
Size: 413 Bytes
Versions: 1
Compression:
Stored size: 413 Bytes
Contents
class RecursiveClosedStruct def initialize(hash) @hash = hash end def include?(key) @hash.include?(key) end def method_missing(name, *) value = fetch(name) if value.is_a?(Hash) self.class.new(value) else value end end private def fetch(name) @hash.fetch(name) do raise NoMethodError.new("undefined method `#{name}' for #{self}") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
prawn_cocktail-0.8.1 | lib/prawn_cocktail/utils/recursive_closed_struct.rb |