module Poise::Helpers::Fused::ClassMethods
@!classmethods
Public Instance Methods
action(name, &block)
click to toggle source
Define a provider action. The block should contain the usual provider code.
@param name [Symbol] Name of the action. @param block [Proc] Action implementation. @example
action(:run) do file '/temp' do user 'root' content 'temp' end end
# 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
fused_actions()
click to toggle source
Storage accessor for fused action blocks. Maps action name to proc.
@api private @return [Hash<Symbol, Proc>]
# File lib/poise/helpers/fused.rb, line 89 def fused_actions (@fused_actions ||= {}) end
fused_provider_class()
click to toggle source
Create a provider class for the fused actions in this resource. Inherits from the fused provider class of the resource's superclass if present.
@api private @return [Class]
# File lib/poise/helpers/fused.rb, line 99 def fused_provider_class @fused_provider_class ||= begin provider_superclass = begin self.superclass.fused_provider_class rescue NoMethodError Chef::Provider end actions = fused_actions class_name = self.name Class.new(provider_superclass) do include Poise define_singleton_method(:name) { class_name + ' (fused)' } actions.each do |action, block| define_method(:"action_#{action}", &block) end end end end
included(klass)
click to toggle source
Calls superclass method
# File lib/poise/helpers/fused.rb, line 118 def included(klass) super klass.extend(ClassMethods) end