diff options
Diffstat (limited to 'lib/chef/node/immutable_collections.rb')
-rw-r--r-- | lib/chef/node/immutable_collections.rb | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/lib/chef/node/immutable_collections.rb b/lib/chef/node/immutable_collections.rb index 56b8fed3b7..0e2800641a 100644 --- a/lib/chef/node/immutable_collections.rb +++ b/lib/chef/node/immutable_collections.rb @@ -75,12 +75,9 @@ class Chef # Redefine all of the methods that mutate a Hash to raise an error when called. # This is the magic that makes this object "Immutable" DISALLOWED_MUTATOR_METHODS.each do |mutator_method_name| - # Ruby 1.8 blocks can't have block arguments, so we must use string eval: - class_eval(<<-METHOD_DEFN, __FILE__, __LINE__) - def #{mutator_method_name}(*args, &block) - raise Exceptions::ImmutableAttributeModification - end - METHOD_DEFN + define_method(mutator_method_name) do |*args, &block| + raise Exceptions::ImmutableAttributeModification + end end # For elements like Fixnums, true, nil... @@ -164,12 +161,9 @@ class Chef # Redefine all of the methods that mutate a Hash to raise an error when called. # This is the magic that makes this object "Immutable" DISALLOWED_MUTATOR_METHODS.each do |mutator_method_name| - # Ruby 1.8 blocks can't have block arguments, so we must use string eval: - class_eval(<<-METHOD_DEFN, __FILE__, __LINE__) - def #{mutator_method_name}(*args, &block) + define_method(mutator_method_name) do |*args, &block| raise Exceptions::ImmutableAttributeModification end - METHOD_DEFN end def method_missing(symbol, *args) |