Module: KeySmith::Translate

Defined in:
lib/key_smith/translate.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.translate(hash, mapping) ⇒ Object



6
7
8
# File 'lib/key_smith/translate.rb', line 6

def translate(hash, mapping)
  mapping.inject(hash) { |h,(k,v)| h[v] = h.delete(k) if h.has_key?(k); h }
end

Instance Method Details

#translate(mapping = {}) ⇒ Object



17
18
19
# File 'lib/key_smith/translate.rb', line 17

def translate(mapping={})
  KeySmith::Translate.translate(self.dup, mapping)
end

#translate!(mapping) ⇒ Object



12
13
14
15
# File 'lib/key_smith/translate.rb', line 12

def translate!(mapping)
  KeySmith::Translate.translate(self, mapping)

end