Top Level Namespace
Instance Method Summary collapse
Instance Method Details
#flatten_hash(hash) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/fluent/plugin/out_indicative.rb', line 9 def flatten_hash(hash) hash.each_with_object({}) do |(k, v), h| if v.is_a? Hash flatten_hash(v).map do |h_k, h_v| h["#{k}.#{h_k}"] = h_v end elsif v.is_a? Array # Indicative doesn't support arrays so we use the value of the array as a key and set it to true v.each do |item| if item.is_a?(Hash) && item.has_key?("key") && item.has_key?("value") h["#{k}.#{item["key"]}"] = item["value"] else h["#{k}.#{item}"] = true end end else h[k] = v end end end |