Sha256: 33ea225f282be017359dfbf5789f592b58c70a74e5a007085799f12ba12f67f0
Contents?: true
Size: 440 Bytes
Versions: 6
Compression:
Stored size: 440 Bytes
Contents
# coding: utf-8 module Dech class HashKeyMapper class << self def map(hash, mapping) new(hash, mapping).map end end def initialize(hash={}, mapping={}) @hash = hash @mapping = mapping end def map new_hash = {} @hash.each do |k, v| [@mapping[k] || k].flatten.each do |new_key| new_hash[new_key] = v end end new_hash end end end
Version data entries
6 entries across 6 versions & 1 rubygems