Module: Chef::Mixin::LanguageIncludeAttribute

Included in:
Node
Defined in:
lib/chef/mixin/language_include_attribute.rb

Instance Method Summary collapse

Instance Method Details

#include_attribute(*args) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/chef/mixin/language_include_attribute.rb', line 25

def include_attribute(*args)
  if self.kind_of?(Chef::Node)
    node = self
  else
    node = @node
  end

  args.flatten.each do |attrib|
    if node.run_state[:seen_attributes].has_key?(attrib)
      Chef::Log.debug("I am not loading attribute file #{attrib}, because I have already seen it.")
      next
    end

    Chef::Log.debug("Loading Attribute #{attrib}")
    node.run_state[:seen_attributes][attrib] = true

    if amatch = attrib.match(/(.+?)::(.+)/)
      cookbook = @cookbook_loader[amatch[1].to_sym]
      cookbook.load_attribute(amatch[2], node)
    else
      cookbook = @cookbook_loader[amatch[1].to_sym]
      cookbook.load_attribute("default", node)
    end
  end
  true
end