Sha256: dd364bdd8dcc987f16b8a12af4d42e425c34081f8627d6572786dcc2d911c2d6
Contents?: true
Size: 556 Bytes
Versions: 4
Compression:
Stored size: 556 Bytes
Contents
class Hash # { foo: :bar }.to_hwia # # { foo: :bar }.to_hwia :foo, :bar # create struct and fill def to_hwia *args if args.first.nil? HashWia.new self else list = args.map(&:to_s).flatten extra = keys.map(&:to_s) - 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] o[k] = self[k.to_sym] if o[k].nil? end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
hash_wia-0.8.6 | ./lib/hash_wia/pollute.rb |
hash_wia-0.8.4 | ./lib/hash_wia/pollute.rb |
hash_wia-0.8.3 | ./lib/hash_wia/pollute.rb |
hash_wia-0.8.2 | ./lib/hash_wia/pollute.rb |