module NewRelic::Agent::EncodingNormalizer

Public Class Methods

normalize_object(object) click to toggle source
# File lib/new_relic/agent/encoding_normalizer.rb, line 14
def self.normalize_object(object)
  case object
  when String
    normalize_string(object)
  when Symbol
    normalize_string(object.to_s)
  when Array
    return object if object.empty?

    object.map { |x| normalize_object(x) }
  when Hash
    return object if object.empty?

    hash = {}
    object.each_pair do |k, v|
      k = normalize_string(k) if k.is_a?(String)
      k = normalize_string(k.to_s) if k.is_a?(Symbol)
      hash[k] = normalize_object(v)
    end
    hash
  when Rational
    object.to_f
  else
    object
  end
end
normalize_string(raw_string) click to toggle source
# File lib/new_relic/agent/encoding_normalizer.rb, line 10
def self.normalize_string(raw_string)
  EncodingNormalizer.normalize(raw_string)
end