class BingAdsRubySdk::Preprocessors::Camelize

Constants

BLACKLIST

Public Class Methods

new(params) click to toggle source
# File lib/bing_ads_ruby_sdk/preprocessors/camelize.rb, line 7
def initialize(params)
  @params = params
end

Public Instance Methods

call() click to toggle source
# File lib/bing_ads_ruby_sdk/preprocessors/camelize.rb, line 11
def call
  process(@params)
end

Private Instance Methods

camelize(string) click to toggle source
# File lib/bing_ads_ruby_sdk/preprocessors/camelize.rb, line 38
def camelize(string)
  BingAdsRubySdk::StringUtils.camelize(string)
end
process(obj) click to toggle source

NOTE: there is a potential for high memory usage here as we're using recursive method calling

# File lib/bing_ads_ruby_sdk/preprocessors/camelize.rb, line 18
def process(obj)
  return obj unless obj.is_a?(Hash)

  obj.each_with_object({}) do |(k, v), h|
    case v
    when Hash then v = process(v)
    when Array then v = v.map {|elt| process(elt) }
    end
    h[transform_key(k.to_s)] = v
  end
end
transform_key(key) click to toggle source
# File lib/bing_ads_ruby_sdk/preprocessors/camelize.rb, line 30
def transform_key(key)
  if BLACKLIST.include?(key)
    key
  else
    camelize(key)
  end
end