Module: YandexApiDirect::YandexObject::YandexObjectInstance
- Defined in:
- lib/yandex-api-direct/yandex_object.rb
Overview
Instance methods for Yandex objects
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Object
fix input arguments.
-
#underscore_keys(hash) ⇒ Object
Change Camelized keys of hash to underscored keys.
Instance Method Details
#initialize(args = {}) ⇒ Object
fix input arguments
54 55 56 |
# File 'lib/yandex-api-direct/yandex_object.rb', line 54 def initialize args = {} super underscore_keys(args) end |
#underscore_keys(hash) ⇒ Object
Change Camelized keys of hash to underscored keys
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/yandex-api-direct/yandex_object.rb', line 40 def underscore_keys(hash) return nil unless hash hash.inject({}){|result, (key, value)| new_key = key.to_s.underscore.to_sym new_value = case value when Hash then underscore_keys(value) else value end result[new_key] = new_value result } end |