Module: RecombeeApiClient::HashNormalizer
- Included in:
- ApiRequest
- Defined in:
- lib/recombee_api_client/api/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/api/hash_normalizer.rb', line 17 def camelize str str.gsub(/_(.)/) {|e| $1.upcase} end |
#normalize_optional(opts) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/recombee_api_client/api/hash_normalizer.rb', line 6 def normalize_optional opts opts_new = {} opts.each do |k,v| case k when String then opts_new[camelize(k)] = opts.delete(k) when Symbol then opts_new[camelize(k.to_s)] = opts.delete(k) end end opts_new end |