Module: RecombeeApiClient::HashNormalizer
- Included in:
- ApiRequest, Input
- Defined in:
- lib/recombee_api_client/utils/hash_normalizer.rb
Overview
Module to convert Ruby conventions to Recombee’s API namings
Instance Method Summary collapse
Instance Method Details
#camelize(str) ⇒ Object
17 18 19 |
# File 'lib/recombee_api_client/utils/hash_normalizer.rb', line 17 def camelize(str) str.gsub(/_(.)/) { |_e| ::Regexp.last_match(1).upcase } end |
#normalize_hash_to_camel_case(h) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/recombee_api_client/utils/hash_normalizer.rb', line 6 def normalize_hash_to_camel_case(h) return h unless h.is_a?(Hash) h_new = {} h.each do |k, v| key = k.is_a?(String) ? camelize(k) : camelize(k.to_s) h_new[key] = v end h_new end |