summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Davis <ryand-ruby@zenspider.com>2011-01-12 16:57:45 -0800
committerDaniel DeLeo <dan@opscode.com>2011-03-22 15:39:02 -0700
commit73375ad2ca693bf6f197f5e436525f54048dc2d0 (patch)
treed4ee22f25e9293dba737f1e5147321b5ef148fa5
parent60d28c312c6dafa4511c064ce290fc1a0cb8e3d2 (diff)
downloadchef-73375ad2ca693bf6f197f5e436525f54048dc2d0.tar.gz
Refactored tags attrib to its own lazy accessor
-rw-r--r--chef/lib/chef/node.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/chef/lib/chef/node.rb b/chef/lib/chef/node.rb
index c15d660101..fd8f4d9146 100644
--- a/chef/lib/chef/node.rb
+++ b/chef/lib/chef/node.rb
@@ -390,7 +390,13 @@ class Chef
normal_attrs_to_merge = consume_run_list(attrs)
Chef::Log.debug("Applying attributes from json file")
@normal_attrs = Chef::Mixin::DeepMerge.merge(@normal_attrs,normal_attrs_to_merge)
- self[:tags] = Array.new unless attribute?(:tags)
+ self.tags # make sure they're defined
+ end
+
+ # Lazy initializer for tags attribute
+ def tags
+ self[:tags] = [] unless attribute?(:tags)
+ self[:tags]
end
# Extracts the run list from +attrs+ and applies it. Returns the remaining attributes
@@ -429,7 +435,8 @@ class Chef
expansion = run_list.expand(chef_environment, data_source)
raise Chef::Exceptions::MissingRole if expansion.errors?
- self[:tags] = Array.new unless attribute?(:tags)
+ self.tags # make sure they're defined
+
@automatic_attrs[:recipes] = expansion.recipes
@automatic_attrs[:roles] = expansion.roles