Class: SimpleCommand::Dispatcher::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_command_dispatcher/configuration.rb

Overview

Gem configuration settings class. Use this class to configure this gem.

To configure this gem in your application, simply add the following code in your application and set the appropriate configuration settings.

Examples:


SimpleCommand::Dispatcher.configure do |config|
   config.allow_custom_commands = true
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



29
30
31
32
# File 'lib/simple_command_dispatcher/configuration.rb', line 29

def initialize
  # The default is to use any command that exposes a ::call class method.
  reset
end

Instance Attribute Details

#allow_custom_commandsBoolean

Gets/sets the allow_custom_commands configuration setting (defaults to false). If this setting is set to false, only command classes that prepend the SimpleCommand module will be considered acceptable to run, all other command classes will fail to run. If this setting is set to true, any command class will be considered acceptable to run, regardless of whether or not the class prepends the SimpleCommand module.

For information about the simple_command gem, visit https://rubygems.org/gems/simple_command

Returns:

  • (Boolean)

    the value.



27
28
29
# File 'lib/simple_command_dispatcher/configuration.rb', line 27

def allow_custom_commands
  @allow_custom_commands
end

Instance Method Details

#resetnil

Resets the configuration to use the default values.

Returns:

  • (nil)

    returns nil.



38
39
40
41
# File 'lib/simple_command_dispatcher/configuration.rb', line 38

def reset
  @allow_custom_commands = false
  nil
end