diff options
author | danielsdeleo <dan@opscode.com> | 2013-04-24 09:36:02 -0700 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2013-04-24 11:04:37 -0700 |
commit | 7639ae987aaf7fe573ee0e50feb284fbedca1171 (patch) | |
tree | cac878e323d71782e36f3df0d41ec9cf0384af51 /lib | |
parent | c6b52cd6e1900a0127d791cbb8241e14da6fc989 (diff) | |
download | chef-7639ae987aaf7fe573ee0e50feb284fbedca1171.tar.gz |
[CHEF-4123] fix const_defined arity mismatch on ruby 1.8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/resource.rb | 11 | ||||
-rw-r--r-- | lib/chef/resource/lwrp_base.rb | 2 |
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. |