lib/chef_metal/inline_resource.rb in chef-metal-0.4 vs lib/chef_metal/inline_resource.rb in chef-metal-0.5
- old
+ new
@@ -1,52 +1,55 @@
module ChefMetal
class InlineResource
- def initialize(provider)
- @provider = provider
+ def initialize(action_handler)
+ @action_handler = action_handler
end
- attr_reader :provider
+ attr_reader :action_handler
- def run_context
- provider.run_context
+ def recipe_context
+ action_handler.recipe_context
end
def method_missing(method_symbol, *args, &block)
# Stolen ruthlessly from Chef's chef/dsl/recipe.rb
# Checks the new platform => short_name => resource mapping initially
# then fall back to the older approach (Chef::Resource.const_get) for
# backward compatibility
- resource_class = Chef::Resource.resource_for_node(method_symbol, provider.run_context.node)
+ resource_class = Chef::Resource.resource_for_node(method_symbol,
+ action_handler.recipe_context.node)
super unless resource_class
raise ArgumentError, "You must supply a name when declaring a #{method_symbol} resource" unless args.size > 0
# If we have a resource like this one, we want to steal its state
- args << run_context
+ args << recipe_context
resource = resource_class.new(*args)
resource.source_line = caller[0]
resource.load_prior_resource
- resource.cookbook_name = provider.cookbook_name
+ resource.cookbook_name = action_handler.debug_name
resource.recipe_name = @recipe_name
resource.params = @params
- # Determine whether this resource is being created in the context of an enclosing Provider
- resource.enclosing_provider = provider.is_a?(Chef::Provider) ? provider : nil
+ # Determine whether this resource is being created in the context of an
+ # enclosing Provider
+ resource.enclosing_provider =
+ action_handler.is_a?(Chef::Provider) ? action_handler : nil
# Evaluate resource attribute DSL
resource.instance_eval(&block) if block
# Run optional resource hook
resource.after_created
# Do NOT put this in the resource collection.
- #run_context.resource_collection.insert(resource)
+ #recipe_context.resource_collection.insert(resource)
# Instead, run the action directly.
Array(resource.action).each do |action|
resource.updated_by_last_action(false)
run_provider_action(resource.provider_for_action(action))
- provider.new_resource.updated_by_last_action(true) if resource.updated_by_last_action?
+ action_handler.updated! if resource.updated_by_last_action?
end
resource
end
# Do Chef::Provider.run_action, but without events
@@ -83,6 +86,6 @@
end
inline_provider.cleanup_after_converge
end
end
-end
\ No newline at end of file
+end