class Hash

Extensions to stdlib Hash

Public Instance Methods

cleanse() click to toggle source

Drop any key-value pairs where the value is not truthy

# File lib/wavefront-sdk/stdlib/hash.rb, line 19
def cleanse
  select { |_k, v| v }
end
to_wf_tag() click to toggle source

Convert a tag hash into a string. The quoting is recommended in the WF wire-format guide. No validation is performed here.

# File lib/wavefront-sdk/stdlib/hash.rb, line 11
def to_wf_tag
  map do |k, v|
    format('%<key>s="%<value>s"', key: k, value: v.tagescape)
  end.join(' ')
end