summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2013-04-24 09:36:02 -0700
committerdanielsdeleo <dan@opscode.com>2013-04-24 09:36:02 -0700
commit4f8ccc5b63e6e124c1222b997a5626e3aeb93742 (patch)
treed959b634b8730696eb02001f367b123838855a1f
parent4aea53a2e8d46dc2ced0eee5ed9b3bbc63e9170c (diff)
downloadchef-CHEF-4123.tar.gz
[CHEF-4123] fix const_defined arity mismatch on ruby 1.8CHEF-4123
-rw-r--r--lib/chef/resource.rb11
-rw-r--r--lib/chef/resource/lwrp_base.rb2
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index bf5e43443e..eb8d7bbf05 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -129,6 +129,17 @@ F
extend Chef::Mixin::ConvertToClassName
+
+ if Module.method(:const_defined?).arity == 1
+ def self.strict_const_defined?(const)
+ const_defined?(const)
+ end
+ else
+ def self.strict_const_defined?(const)
+ const_defined?(const, false)
+ end
+ end
+
# Track all subclasses of Resource. This is used so names can be looked up
# when attempting to deserialize from JSON. (See: json_compat)
def self.resource_classes
diff --git a/lib/chef/resource/lwrp_base.rb b/lib/chef/resource/lwrp_base.rb
index 5776bb59fb..3309ee3cb8 100644
--- a/lib/chef/resource/lwrp_base.rb
+++ b/lib/chef/resource/lwrp_base.rb
@@ -39,7 +39,7 @@ class Chef
# Add log entry if we override an existing light-weight resource.
class_name = convert_to_class_name(rname)
- if Resource.const_defined?(class_name, false)
+ if Resource.strict_const_defined?(class_name)
old_class = Resource.send(:remove_const, class_name)
# CHEF-3432 -- Chef::Resource keeps a list of subclasses; need to
# remove old ones from the list when replacing.