module Poise::Helpers::Inversion::Resource::ClassMethods
@!classmethods
Attributes
inversion_options_provider_class[R]
Options provider class.
inversion_options_resource_class[R]
Options resource class.
Public Instance Methods
create_inversion_options_resource!(name)
click to toggle source
Create resource and provider classes for an options resource.
@param name [String, Symbol] DSL name for the base resource. @return [void]
# File lib/poise/helpers/inversion.rb, line 127 def create_inversion_options_resource!(name) enclosing_class = self options_resource_name = :"#{name}_options" # Create the resource class. @inversion_options_resource_class = Class.new(Chef::Resource) do include Poise::Helpers::Inversion::OptionsResource define_singleton_method(:name) do "#{enclosing_class}::OptionsResource" end define_singleton_method(:inversion_resource_class) do enclosing_class end provides(options_resource_name) inversion_resource(name) end # Create the provider class. @inversion_options_provider_class = Class.new(Chef::Provider) do include Poise::Helpers::Inversion::OptionsProvider define_singleton_method(:name) do "#{enclosing_class}::OptionsProvider" end define_singleton_method(:inversion_resource_class) do enclosing_class end provides(options_resource_name) end end
included(klass)
click to toggle source
Calls superclass method
Poise::Helpers::Inversion::OptionsProvider::included
# File lib/poise/helpers/inversion.rb, line 164 def included(klass) super klass.extend(ClassMethods) end
inversion_options_resource(val=nil)
click to toggle source
@overload inversion_options_resource
()
Return the options resource mode for this class. @return [Boolean]
@overload inversion_options_resource
(val)
Set the options resource mode for this class. Set to true to automatically create an options resource. Defaults to true. @param val [Boolean] Enable/disable setting. @return [Boolean]
# File lib/poise/helpers/inversion.rb, line 118 def inversion_options_resource(val=nil) @poise_inversion_options_resource = val unless val.nil? @poise_inversion_options_resource end
provides(name, *args, &block)
click to toggle source
Wrap provides()
to create an options resource if desired.
@param name [Symbol] Resource
name return [void]
Calls superclass method
# File lib/poise/helpers/inversion.rb, line 159 def provides(name, *args, &block) create_inversion_options_resource!(name) if inversion_options_resource super(name, *args, &block) if defined?(super) end