method

invoke_from_option

ruby latest stable - Class: Bundler::Thor::Group

Method not available on this version

This method is only available on newer versions. The first available version (v2_6_3) is shown here.

invoke_from_option(*names, &block)
public

Invoke a thor class based on the value supplied by the user to the given option named “name”. A class option must be created before this method is invoked for each name given.

Examples

class GemGenerator < Bundler::Thor::Group
  class_option :test_framework, :type => :string
  invoke_from_option :test_framework
end

Boolean options

In some cases, you want to invoke a thor class if some option is true or false. This is automatically handled by invoke_from_option. Then the option name is used to invoke the generator.

Preparing for invocation

In some cases you want to customize how a specified hook is going to be invoked. You can do that by overwriting the class method prepare_for_invocation. The class method must necessarily return a klass and an optional command.

Custom invocations

You can also supply a block to customize how the option is going to be invoked. The block receives two parameters, an instance of the current class and the klass to be invoked.