Method: NewRelic::Agent::AttributeProcessing.flatten_and_coerce_array

Defined in:
lib/new_relic/agent/attribute_processing.rb

.flatten_and_coerce_array(array, prefix, result, &blk) ⇒ Object

[View source]

46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/new_relic/agent/attribute_processing.rb', line 46

def flatten_and_coerce_array(array, prefix, result, &blk)
  if array.empty?
    if blk
      yield(prefix, EMPTY_ARRAY_STRING_LITERAL)
    else
      result[prefix] = EMPTY_ARRAY_STRING_LITERAL
    end
  else
    array.each_with_index do |val, idx|
      next_prefix = prefix ? "#{prefix}.#{idx}" : idx.to_s
      flatten_and_coerce(val, next_prefix, result, &blk)
    end
  end
end