Module: Poise::Helpers::Fused

Defined in:
lib/poise/helpers/fused.rb

Overview

Resource mixin to create "fused" resources where the resource and provider are implemented in the same class.

Examples:

class Chef::Resource::MyResource < Chef::Resource
  include Poise(fused: true)
  attribute(:path, kind_of: String)
  attribute(:message, kind_of: String)
  action(:run) do
    file new_resource.path do
      content new_resource.message
    end
  end
end

Since:

  • 2.0.0

Class Method Summary collapse

Class Method Details

.action(name, &block) ⇒ Object

Define a provider action. The block should contain the usual provider code.

Examples:

action(:run) do
  file '/temp' do
    user 'root'
    content 'temp'
  end
end

Parameters:

  • name (Symbol)

    Name of the action.

  • block (Proc)

    Action implementation.

Since:

  • 2.0.0



77
78
79
80
81
82
83
# File 'lib/poise/helpers/fused.rb', line 77

def action(name, &block)
  fused_actions[name.to_sym] = block
  # Make sure this action is allowed, also sets the default if first.
  if respond_to?(:actions)
    actions(name.to_sym)
  end
end