module RecombeeApiClient::HashNormalizer

Module to convert Ruby conventions to Recombee's API namings

Public Instance Methods

camelize(str) click to toggle source
# File lib/recombee_api_client/api/hash_normalizer.rb, line 17
def camelize str
  str.gsub(/_(.)/) {|e| $1.upcase}
end
normalize_optional(opts) click to toggle source
# 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