summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2015-05-27 10:40:55 -0700
committerJohn Keiser <john@johnkeiser.com>2015-05-28 13:27:44 -0700
commit81e4fa499bb792ca53ffd362a88067c858c33211 (patch)
treede9275d089daf0da6dca4d97bde0bb299b01b253 /lib
parent6d1b736f6d581fb6a63f5b51708b0a75c566321e (diff)
downloadchef-81e4fa499bb792ca53ffd362a88067c858c33211.tar.gz
Fix up deprecated_attr_*, add tests
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/mixin/deprecation.rb36
1 files changed, 16 insertions, 20 deletions
diff --git a/lib/chef/mixin/deprecation.rb b/lib/chef/mixin/deprecation.rb
index c7923a5efb..a3eacf75cb 100644
--- a/lib/chef/mixin/deprecation.rb
+++ b/lib/chef/mixin/deprecation.rb
@@ -100,28 +100,24 @@ class Chef
deprecated_attr_writer(name, alternative)
end
- def deprecated_attr_reader(name, alternative)
- instance_eval <<-EOM
- def #{name}(value)
- Chef::Log.deprecation("#{self}.#{name} is deprecated. Support will be removed in a future release.")
- Chef::Log.deprecation(#{alternative.inspect})
- Chef::Log.deprecation("Called from:")
- caller[0..3].each {|l| log(l)}
- @#{name}
- end
- EOM
+ def deprecated_attr_reader(name, alternative, level=:warn)
+ define_method(name) do
+ Chef::Log.deprecation("#{self.class}.#{name} is deprecated. Support will be removed in a future release.")
+ Chef::Log.deprecation(alternative)
+ Chef::Log.deprecation("Called from:")
+ caller[0..3].each {|c| Chef::Log.deprecation(c)}
+ instance_variable_get("@#{name}")
+ end
end
- def deprecated_attr_writer(name, alternative)
- instance_eval <<-EOM
- def #{name}=(value)
- Chef::Log.deprecation("Writing to #{self}.#{name}= is deprecated. Support will be removed in a future release.")
- Chef::Log.deprecation(#{alternative.inspect})
- Chef::Log.deprecation("Called from:")
- caller[0..3].each {|l| log(l)}
- @#{name} = value
- end
- EOM
+ def deprecated_attr_writer(name, alternative, level=:warn)
+ define_method("#{name}=") do |value|
+ Chef::Log.deprecation("Writing to #{self.class}.#{name} with #{name}= is deprecated. Support will be removed in a future release.")
+ Chef::Log.deprecation(alternative)
+ Chef::Log.deprecation("Called from:")
+ caller[0..3].each {|c| Chef::Log.deprecation(c)}
+ instance_variable_set("@#{name}", value)
+ end
end
end
end