Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/wavefront-sdk/stdlib/hash.rb
Overview
Extensions to stdlib Hash
Instance Method Summary collapse
-
#cleanse ⇒ Object
Drop any key-value pairs where the value is not truthy.
-
#to_wf_tag ⇒ Object
Convert a tag hash into a string.
Instance Method Details
#cleanse ⇒ Object
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_tag ⇒ Object
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 |