@@ -195,6 +195,10 @@ def name(arg=nil)
195195def attribute
196196Chef ::Node ::Attribute . new ( @normal_attrs , @default_attrs , @override_attrs )
197197end
198+
199+ def attribute = ( value )
200+ @normal_attrs = value
201+ end
198202
199203# Return an attribute of this node. Returns nil if the attribute is not found.
200204def []( attrib )
@@ -212,25 +216,25 @@ def store(attrib, value)
212216
213217# Set a normal attribute of this node, but auto-vivifiy any Mashes that
214218# might be missing
215- def set
219+ def normal
216220attrs = Chef ::Node ::Attribute . new ( @normal_attrs , @default_attrs , @override_attrs )
217221attrs . set_type = :normal
218222attrs . auto_vivifiy_on_read = true
219223attrs
220224end
221225
222- alias_method :normal , :set
226+ alias_method :set , :normal
223227
224228# Set a normal attribute of this node, auto-vivifiying any mashes that are
225229# missing, but if the final value already exists, don't set it
226- def set_unless
230+ def normal_unless
227231attrs = Chef ::Node ::Attribute . new ( @normal_attrs , @default_attrs , @override_attrs )
228232attrs . set_type = :normal
229233attrs . auto_vivifiy_on_read = true
230234attrs . set_unless_value_present = true
231235attrs
232236end
233- alias_method :normal_unless , :set_unless
237+ alias_method :set_unless , :normal_unless
234238
235239# Set a default of this node, but auto-vivifiy any Mashes that might
236240# be missing
@@ -293,7 +297,10 @@ def each_attribute(&block)
293297# to set the attribute values. Otherwise, we'll wind up just returning the attributes
294298# value.
295299def method_missing ( symbol , *args )
296- Chef ::Node ::Attribute . new ( @normal_attrs , @default_attrs , @override_attrs ) . send ( symbol , *args )
300+ attrs = Chef ::Node ::Attribute . new ( @normal_attrs , @default_attrs , @override_attrs )
301+ attrs . set_type = :normal
302+ attrs . auto_vivify_on_read = true
303+ attrs . send ( symbol , *args )
297304end
298305
299306# Returns true if this Node expects a given recipe, false if not.
@@ -342,9 +349,9 @@ def to_hash
342349index_hash = Hash . new
343350index_hash [ "chef_type" ] = "node"
344351index_hash [ "name" ] = @name
345- index_hash [ "normal" ] = @normal_attrs
346- index_hash [ "default" ] = @default_attrs
347- index_hash [ "override" ] = @override_attrs
352+ attribute . each do | key , value |
353+ index_hash [ key ] = value
354+ end
348355index_hash [ "recipe" ] = @run_list . recipes if @run_list . recipes . length > 0
349356index_hash [ "role" ] = @run_list . roles if @run_list . roles . length > 0
350357index_hash [ "run_list" ] = @run_list . run_list if @run_list . run_list . length > 0
0 commit comments