class Hash
https://github.com/mickey/black-hole-struct/blob/master/lib/black_hole_struct.rb
Definitions
def self.vivify(&block)
Build a Hash with autovivification via a block DSL.
Hash.vivify { metadata.name = "web" spec.replicas = 3 spec.selector.matchLabels.app = "web" }
=> metadata: { name: "web" , spec: replicas: 3, selector: { matchLabels: { app: "web" } } }
Implementation
def self.vivify(&block)
new.tap { |h| h.instance_exec(&block) }
end