Method: Chef::NodeMap#set

Defined in:
lib/chef/node_map.rb

#set(key, value, filters = {}) {|node| ... } ⇒ NodeMap

Set a key/value pair on the map with a filter. The filter must be true when applied to the node in order to retrieve the value.

Parameters:

  • key (Object)

    Key to store

  • value (Object)

    Value associated with the key

  • filters (Hash) (defaults to: {})

    Node filter options to apply to key retrieval

Yields:

  • (node)

    Arbitrary node filter as a block which takes a node argument

Returns:

  • (NodeMap)

    Returns self for possible chaining



50
51
52
53
54
55
56
57
58
59
# File 'lib/chef/node_map.rb', line 50

def set(key, value, filters = {}, &block)
  validate_filter!(filters)
  deprecate_filter!(filters)
  @map[key] ||= []
  # we match on the first value we find, so we want to unshift so that the
  # last setter wins
  # FIXME: need a test for this behavior
  @map[key].unshift({ filters: filters, block: block, value: value })
  self
end