Class: Bling::API::Translator
- Inherits:
-
Object
- Object
- Bling::API::Translator
- Defined in:
- lib/bling/api/translator.rb
Class Method Summary collapse
Class Method Details
.translate_hash(hash, to: :en) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/bling/api/translator.rb', line 18 def translate_hash(hash, to: :en) conversion_hash = send(to) hash.inject({}) do |result, (key, value)| new_key = conversion_hash[underscore_symbol(key)] new_key = underscore_symbol(key) if new_key.nil? new_value = case value when Hash then translate_hash(value, to: to) when Array then value.map! { |v| translate_hash(v, to: to) } else value end result[new_key] = new_value result end end |
.translate_url(key, id: nil) ⇒ Object
12 13 14 15 16 |
# File 'lib/bling/api/translator.rb', line 12 def translate_url(key, id: nil) url = pt[key.to_sym].to_s url +="/#{id}" if id url end |