summaryrefslogtreecommitdiff
path: root/lib/chef/resource.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/resource.rb')
-rw-r--r--lib/chef/resource.rb45
1 files changed, 22 insertions, 23 deletions
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index 5c230ad2f4..6c2f91ed8b 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -29,7 +29,7 @@ require 'chef/mixin/convert_to_class_name'
require 'chef/guard_interpreter/resource_guard_interpreter'
require 'chef/resource/conditional'
require 'chef/resource/conditional_action_not_nothing'
-require 'chef/resource/action_provider'
+require 'chef/resource/action_class'
require 'chef/resource_collection'
require 'chef/node_map'
require 'chef/node'
@@ -688,7 +688,7 @@ class Chef
# The provider class for this resource.
#
# If `action :x do ... end` has been declared on this resource or its
- # superclasses, this will return the `action_provider_class`.
+ # superclasses, this will return the `action_class`.
#
# If this is not set, `provider_for_action` will dynamically determine the
# provider.
@@ -699,7 +699,7 @@ class Chef
#
# @return The provider class for this resource.
#
- # @see Chef::Resource.action_provider_class
+ # @see Chef::Resource.action_class
#
def provider(arg=nil)
klass = if arg.kind_of?(String) || arg.kind_of?(Symbol)
@@ -708,7 +708,7 @@ class Chef
arg
end
set_or_return(:provider, klass, kind_of: [ Class ]) ||
- self.class.action_provider_class
+ self.class.action_class
end
def provider=(arg)
provider(arg)
@@ -1372,7 +1372,8 @@ class Chef
#
def self.action(action, &recipe_block)
action = action.to_sym
- new_action_provider_class.action(action, &recipe_block)
+ declare_action_class
+ action_class.action(action, &recipe_block)
self.allowed_actions += [ action ]
default_action action if Array(default_action) == [:nothing]
end
@@ -1416,7 +1417,7 @@ class Chef
end
#
- # The action provider class is an automatic `Provider` created to handle
+ # The action class is an automatic `Provider` created to handle
# actions declared by `action :x do ... end`.
#
# This class will be returned by `resource.provider` if `resource.provider`
@@ -1425,40 +1426,38 @@ class Chef
#
# If the user has not declared actions on this class or its superclasses
# using `action :x do ... end`, then there is no need for this class and
- # `action_provider_class` will be `nil`.
+ # `action_class` will be `nil`.
#
# @api private
#
- def self.action_provider_class
- @action_provider_class ||
+ def self.action_class
+ @action_class ||
# If the superclass needed one, then we need one as well.
- if superclass.respond_to?(:action_provider_class) && superclass.action_provider_class
- new_action_provider_class
+ if superclass.respond_to?(:action_class) && superclass.action_class
+ declare_action_class
end
end
#
- # Ensure the action provider class actually gets created. This is called
+ # Ensure the action class actually gets created. This is called
# when the user does `action :x do ... end`.
#
+ # If a block is passed, it is run inside the action_class.
+ #
# @api private
- def self.new_action_provider_class
- return @action_provider_class if @action_provider_class
+ def self.declare_action_class
+ return @action_class if @action_class
- if superclass.respond_to?(:action_provider_class)
- base_provider = superclass.action_provider_class
+ if superclass.respond_to?(:action_class)
+ base_provider = superclass.action_class
end
base_provider ||= Chef::Provider
resource_class = self
- @action_provider_class = Class.new(base_provider) do
- include ActionProvider
- define_singleton_method(:to_s) { "#{resource_class} action provider" }
- def self.inspect
- to_s
- end
+ @action_class = Class.new(base_provider) do
+ include ActionClass
+ self.resource_class = resource_class
end
- @action_provider_class
end
#