Module: Garcon::Resource::Blender::ClassMethods
- Included in:
- Garcon::Resource::Blender
- Defined in:
- lib/garcon/chef/resource/blender.rb
Instance Method Summary collapse
-
#action(name, &block) ⇒ Object
Define a provider action.
-
#blender_actions ⇒ Hash<Symbol, Proc>
private
Storage accessor for blended action blocks.
-
#blender_provider_class ⇒ Class
private
Create a provider class for the blender actions in this resource.
-
#included(descendant) ⇒ self
private
Hook called when module is included, extends a descendant with class and instance methods.
Instance Method Details
#action(name, &block) ⇒ Object
Define a provider action. The block should contain the usual provider code.
81 82 83 84 |
# File 'lib/garcon/chef/resource/blender.rb', line 81 def action(name, &block) blender_actions[name.to_sym] = block actions(name.to_sym) if respond_to?(:actions) end |
#blender_actions ⇒ Hash<Symbol, Proc>
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.
Storage accessor for blended action blocks. Maps action name to proc.
91 92 93 |
# File 'lib/garcon/chef/resource/blender.rb', line 91 def blender_actions (@blender_actions ||= {}) end |
#blender_provider_class ⇒ Class
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.
Create a provider class for the blender actions in this resource. Inherits from the blender provider class of the resource’s superclass if present.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/garcon/chef/resource/blender.rb', line 102 def blender_provider_class @blender_provider_class ||= begin provider_superclass = begin self.superclass.blender_provider_class rescue NoMethodError Chef::Provider end actions = blender_actions class_name = self.name Class.new(provider_superclass) do include Garcon define_singleton_method(:name) { class_name + ' (blender)' } actions.each do |action, block| define_method(:"action_#{action}", &block) end end end end |
#included(descendant) ⇒ self
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.
Hook called when module is included, extends a descendant with class and instance methods.
130 131 132 133 |
# File 'lib/garcon/chef/resource/blender.rb', line 130 def included(descendant) super descendant.extend ClassMethods end |