summaryrefslogtreecommitdiff
path: root/chef/lib/chef/node
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2012-10-04 21:08:59 -0700
committerBryan McLellan <btm@opscode.com>2012-10-15 16:09:33 -0700
commitf8b8a76654a93426c47877456bb01bcc24b9a04f (patch)
treebf82fa0eeba3ec6f3ba1b51f39a25a6735455df3 /chef/lib/chef/node
parente44068991683897595665cec0dc169d88c22d14a (diff)
downloadchef-f8b8a76654a93426c47877456bb01bcc24b9a04f.tar.gz
disallow []= without explicit precedence
Diffstat (limited to 'chef/lib/chef/node')
-rw-r--r--chef/lib/chef/node/attribute.rb20
1 files changed, 10 insertions, 10 deletions
diff --git a/chef/lib/chef/node/attribute.rb b/chef/lib/chef/node/attribute.rb
index c4556bfeae..36bc721b77 100644
--- a/chef/lib/chef/node/attribute.rb
+++ b/chef/lib/chef/node/attribute.rb
@@ -23,6 +23,10 @@ require 'chef/log'
class Chef
class Node
class Attribute
+
+ class ImmutableAttribute < NoMethodError
+ end
+
HIDDEN_ATTRIBUES = [:@override, :@attribute, :@default, :@normal, :@automatic]
attr_accessor :normal,
@@ -55,14 +59,6 @@ class Chef
@has_been_read = false
end
- def attribute
- normal
- end
-
- def attribute=(value)
- normal = value
- end
-
def set_type_hash
case @set_type
when :normal
@@ -317,8 +313,12 @@ class Chef
end
def []=(key, value)
- # If we don't have one, then we'll pretend we're normal
- @set_type ||= :normal
+ if @set_type.nil?
+ # @set_type = :normal
+ raise ImmutableAttribute, "Attributes may only be set by specifying the precedence level, e.g., node.normal[:foo] = 'bar'"
+ elsif @set_type == false
+ raise "WTF"
+ end
if set_unless_value_present
if get_value(set_type_hash, key) != nil