Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/hash_wia/pollute.rb

Direct Known Subclasses

HashWia

Instance Method Summary collapse

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