module Aws::Xray::AnnotationNormalizer

For specification: docs.aws.amazon.com/xray/latest/devguide/xray-api-segmentdocuments.html

Constants

INVALID_PATTERN

Public Instance Methods

call(h) click to toggle source

@param [Hash] h annotation hash. @return [Hash]

# File lib/aws/xray/annotation_normalizer.rb, line 9
def call(h)
  h.inject({}) {|init, (k, v)| init[normalize_key(k)] = normalize_value(v); init }
end

Private Instance Methods

normalize_key(k) click to toggle source
  • Convert keys which including '-' to '_' because it might be common pit-fall.

  • Remove invalid chars.

# File lib/aws/xray/annotation_normalizer.rb, line 19
def normalize_key(k)
  k.to_s.gsub('-', '_').gsub(INVALID_PATTERN, '').to_sym
end
normalize_value(v) click to toggle source
# File lib/aws/xray/annotation_normalizer.rb, line 23
def normalize_value(v)
  case v
  when nil
    nil
  when Integer, Float
    v
  when true, false
    v
  else
    v.to_s
  end
end