Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/wavefront-sdk/stdlib/hash.rb

Overview

Extensions to stdlib Hash

Instance Method Summary collapse

Instance Method Details

#cleanseObject

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



19
20
21
# File 'lib/wavefront-sdk/stdlib/hash.rb', line 19

def cleanse
  select { |_k, v| v }
end

#to_wf_tagObject

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



11
12
13
14
15
# 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