module Poise::Helpers::Inversion::OptionsResource
A mixin for inversion options resources.
@api private @since 2.0.0 @see Poise::Helpers::Inversion
Public Instance Methods
after_created()
click to toggle source
Insert the options data in to the run state. This has to match the layout used in {Poise::Helpers::Inversion::Provider.inversion_options}.
@api private
# File lib/poise/helpers/inversion/options_resource.rb, line 69 def after_created raise Poise::Error.new("Inversion resource name not set for #{self.class.name}") unless self.class.inversion_resource node.run_state['poise_inversion'] ||= {} node.run_state['poise_inversion'][self.class.inversion_resource] ||= {} node.run_state['poise_inversion'][self.class.inversion_resource][resource] ||= {} node.run_state['poise_inversion'][self.class.inversion_resource][resource][for_provider] ||= {} node.run_state['poise_inversion'][self.class.inversion_resource][resource][for_provider].update(_options) end
method_missing(method_sym, *args, &block)
click to toggle source
Method missing delegation to allow DSL-style options.
@example
my_app_options 'app' do key1 'value1' key2 'value2' end
Calls superclass method
# File lib/poise/helpers/inversion/options_resource.rb, line 41 def method_missing(method_sym, *args, &block) super(method_sym, *args, &block) rescue NoMethodError # First time we've seen this key and using it as an rvalue, NOPE.GIF. raise unless !args.empty? || block || _options[method_sym] if !args.empty? || block _options[method_sym] = block || args.first end _options[method_sym] end
provider(val=Poise::NOT_PASSED)
click to toggle source
Capture setting the provider and make it Do What I Mean. This does mean you can't set the actual provider for the options resource, which is fine because the provider is a no-op.
@api private
Calls superclass method
# File lib/poise/helpers/inversion/options_resource.rb, line 57 def provider(val=Poise::NOT_PASSED) if val == Poise::NOT_PASSED super() else _options[:provider] = val end end