Method: Sensu::Utilities#object_substitute_tokens
- Defined in:
- lib/sensu/utilities.rb
#object_substitute_tokens(object, attributes) ⇒ Array
Perform token substitution for an object. String values are passed to ‘substitute_tokens()`, arrays and sub-hashes are processed recursively. Numeric values are ignored.
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/sensu/utilities.rb', line 213 def object_substitute_tokens(object, attributes) unmatched_tokens = [] case object when Hash object.each do |key, value| object[key], unmatched = object_substitute_tokens(value, attributes) unmatched_tokens.push(*unmatched) end when Array object.map! do |value| value, unmatched = object_substitute_tokens(value, attributes) unmatched_tokens.push(*unmatched) value end when String object, unmatched_tokens = substitute_tokens(object, attributes) end [object, unmatched_tokens.uniq] end |