module Firmenwissen::KeyMapper
Constants
- KEY_MAPPINGS
Public Class Methods
from_api(hash)
click to toggle source
# File lib/firmenwissen/key_mapper.rb, line 15 def from_api(hash) map(hash, :from_api) end
to_api(hash)
click to toggle source
# File lib/firmenwissen/key_mapper.rb, line 19 def to_api(hash) map(hash, :to_api) end
Private Class Methods
map(hash, direction)
click to toggle source
# File lib/firmenwissen/key_mapper.rb, line 25 def map(hash, direction) {}.tap do |result| mapping_for(direction).each do |key, value| result[key] = hash[value] end end end
mapping_for(direction)
click to toggle source
# File lib/firmenwissen/key_mapper.rb, line 33 def mapping_for(direction) direction == :from_api ? KEY_MAPPINGS : KEY_MAPPINGS.invert end