summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef/node.rb12
-rw-r--r--spec/unit/node_spec.rb12
2 files changed, 24 insertions, 0 deletions
diff --git a/lib/chef/node.rb b/lib/chef/node.rb
index b75f08f64a..0c49359236 100644
--- a/lib/chef/node.rb
+++ b/lib/chef/node.rb
@@ -138,6 +138,12 @@ class Chef
attributes.default
end
+ # Set a force default attribute. Intermediate mashes will be created by
+ # auto-vivify if necessary.
+ def default!
+ attributes.default!
+ end
+
# Set a default attribute of this node, auto-vivifying any mashes that are
# missing, but if the final value already exists, don't set it
def default_unless
@@ -151,6 +157,12 @@ class Chef
attributes.override
end
+ # Set a force override attribute. Intermediate mashes will be created by
+ # auto-vivify if needed.
+ def override!
+ attributes.override!
+ end
+
# Set an override attribute of this node, auto-vivifying any mashes that
# are missing, but if the final value already exists, don't set it
def override_unless
diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb
index 73075d077b..f8cfd39deb 100644
--- a/spec/unit/node_spec.rb
+++ b/spec/unit/node_spec.rb
@@ -206,6 +206,12 @@ describe Chef::Node do
node.fuu.bahrr.baz.should == "qux"
end
+ it "accesses force defaults via default!" do
+ node.default![:foo] = "wet bar"
+ node.default[:foo] = "bar"
+ node[:foo].should == "wet bar"
+ end
+
end
describe "override attributes" do
@@ -230,6 +236,12 @@ describe Chef::Node do
node.fuu.bahrr.baz.should == "qux"
end
+ it "sets force_overrides via override!" do
+ node.override![:foo] = "wet bar"
+ node.override[:foo] = "bar"
+ node[:foo].should == "wet bar"
+ end
+
end
it "should raise an ArgumentError if you ask for an attribute that doesn't exist via method_missing" do