class Hash
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
def to_yaml(*)
Deep-stringify keys so symbol keys don't leak into YAML as :key:.
Implementation
def to_yaml(*)
Hash._deep_stringify_keys(self).then { |h| Psych.dump(h) }
end