module Chef::Mixin::NotifyingBlock

Public Instance Methods

notifying_block(&block) click to toggle source
# File lib/chef/mixin/notifying_block.rb, line 22
def notifying_block(&block)
  subcontext = subcontext_block(&block)
  Chef::Runner.new(subcontext).converge
ensure
  # recipes don't have a new_resource
  if respond_to?(:new_resource)
    if subcontext && subcontext.resource_collection.any?(&:updated?)
      new_resource.updated_by_last_action(true)
    end
  end
end
subcontext_block(parent_context = nil, &block) click to toggle source
# File lib/chef/mixin/notifying_block.rb, line 34
def subcontext_block(parent_context = nil, &block)
  parent_context ||= @run_context
  sub_run_context = parent_context.create_child

  begin
    outer_run_context = @run_context
    @run_context = sub_run_context
    instance_eval(&block)
  ensure
    @run_context = outer_run_context
  end

  sub_run_context
end