summaryrefslogtreecommitdiff
path: root/lib/chef/resource.rb
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2015-05-28 11:17:10 -0700
committerJohn Keiser <john@johnkeiser.com>2015-06-01 08:02:05 -0700
commit5998cc7315507e649bb76f139c07715f6e590707 (patch)
treeda543eeb9183ba63cfea376c51207b31ed104f65 /lib/chef/resource.rb
parent16dbca593b2fef74d952c5e119313efbe2288670 (diff)
downloadchef-5998cc7315507e649bb76f139c07715f6e590707.tar.gz
Make resource_name call provides
Diffstat (limited to 'lib/chef/resource.rb')
-rw-r--r--lib/chef/resource.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index 78f6a38b34..fdfa9766ab 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -886,15 +886,22 @@ class Chef
#
# The display name of this resource type, for printing purposes.
#
+ # This also automatically calls "provides" to provide DSL with the given
+ # name.
+ #
+ # @param value [Symbol] The desired name of this resource type (e.g.
+ # `execute`).
+ #
# @return [Symbol] The name of this resource type (e.g. `:execute`).
#
- attr_accessor :resource_name
def resource_name(value=NULL_ARG)
if value != NULL_ARG
- self.resource_name = value.to_sym
+ @resource_name = value.to_sym
+ provides self.resource_name
end
@resource_name
end
+ alias :resource_name= :resource_name
#
# The module where Chef should look for providers for this resource.
@@ -1007,8 +1014,6 @@ class Chef
def self.provides(name, *args, &block)
result = super
- # The first time `provides` is called on the class, it is used for resource_name
- self.resource_name ||= name
Chef::DSL::Resources.add_resource_dsl(name)
result
end