Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/hash_wia/pollute.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#to_hwia(*args) ⇒ Object
{ foo: :bar }.to_hwia # { foo: :bar }.to_hwia :foo, :bar # create struct and fill.
Instance Method Details
#to_hwia(*args) ⇒ Object
{ foo: :bar }.to_hwia # { foo: :bar }.to_hwia :foo, :bar # create struct and fill
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/hash_wia/pollute.rb', line 4 def to_hwia *args if args.first.nil? HashWia.new self else list = args.flatten name = 'DynStruct_' + list.join('_') HashWia::STRUCTS[name] ||= ::Struct.new(name, *list) HashWia::STRUCTS[name].new **self end end |