diff options
author | John Keiser <john@johnkeiser.com> | 2015-04-20 16:42:19 -0700 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2015-05-13 13:42:33 -0700 |
commit | a379de8207f33938abac36cf415e0d593aa24d59 (patch) | |
tree | a270f524453d36bd4f0f4a0add4866119396b72d /lib/chef/resource.rb | |
parent | 644342358dcd7202c24f731eae498db1ec46db3d (diff) | |
download | chef-a379de8207f33938abac36cf415e0d593aa24d59.tar.gz |
Add provides_nothing and let it override even Chef::Resource::X automatic names
Diffstat (limited to 'lib/chef/resource.rb')
-rw-r--r-- | lib/chef/resource.rb | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index 280da8734c..194a82b61b 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -978,16 +978,23 @@ class Chef super if subclass.dsl_name subclass.provides subclass.dsl_name.to_sym - subclass.instance_eval { @auto_provides = subclass.dsl_name.to_sym } + subclass.using_automatic_dsl = true end end + def self.using_automatic_dsl? + @using_automatic_dsl + end + + def self.using_automatic_dsl=(value) + @using_automatic_dsl = value + end + def self.provides(name, *args, &block) # If the user specifies provides, then we get rid of the auto-provided DSL # and let them specify what they want - if @auto_provides - @auto_provides = auto_provides = nil - does_not_provide(auto_provides) + if using_automatic_dsl? + provides_nothing end super @@ -995,18 +1002,16 @@ class Chef Chef::DSL::Resources.add_resource_dsl(name) end - def self.does_not_provide(name=nil) - name ||= dsl_name - if @auto_provides - @auto_provides = auto_provides = nil - does_not_provide(auto_provides) if name != auto_provides - end + def self.provides_nothing + @using_automatic_dsl = false - super + unprovided_names = super - # Get rid of the DSL if this was the only resource that used it - if !Chef::Resource.resource_matching_short_name(name) - Chef::DSL::Resources.remove_resource_dsl(name) + unprovided_names.each do |name| + resource = resource_matching_short_name(name) + if !resource || resource == self + Chef::DSL::Resources.remove_resource_dsl(name) + end end end |