class Hash
Public Instance Methods
to_hwia(*args)
click to toggle source
{ foo: :bar }.to_hwia # { foo: :bar }.to_hwia :foo, :bar # create struct and fill
# File lib/hash_wia/pollute.rb, line 4 def to_hwia *args unless args.first HashWia.new self else list = args.flatten extra = keys - list if extra.first raise ArgumentError.new('Unallowed key/s: %s' % extra.map{ |_| ':%s' % _ }.join(', ')) end HashWia.new.tap do |o| list.each do |k| o[k] = self[k] end end end end