Module: Chef::Provider::InlineResources::ClassMethods Private

Defined in:
lib/chef/provider.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Class methods for InlineResources. Overrides the ‘action` DSL method with one that enables inline resource convergence.

Instance Method Summary collapse

Instance Method Details

#action(name, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Defines an action method on the provider, running the block to compile the resources, converging them, and then checking if any were updated (and updating new-resource if so)



379
380
381
382
383
384
385
386
387
388
389
390
391
392
# File 'lib/chef/provider.rb', line 379

def action(name, &block)
  # We need the block directly in a method so that `super` works
  define_method("compile_action_#{name}", &block)
  # We try hard to use `def` because define_method doesn't show the method name in the stack.
  begin
    class_eval <<-EOM
      def action_#{name}
        compile_and_converge_action { compile_action_#{name} }
      end
    EOM
  rescue SyntaxError
    define_method("action_#{name}") { send("compile_action_#{name}") }
  end
end