Class | Thor::Group |
In: |
lib/thor/group.rb
|
Parent: | Object |
Thor has a special class called Thor::Group. The main difference to Thor class is that it invokes all tasks at once. It also include some methods that allows invocations to be done at the class method, which are not available to Thor tasks.
The descrition for this Thor::Group. If none is provided, but a source root exists, tries to find the USAGE one folder above it, otherwise searches in the superclass.
description<String>: | The description for this Thor::Group. |
Invoke the given namespace or class given. It adds an instance method that will invoke the klass and task. You can give a block to configure how it will be invoked.
The namespace/class given will have its options showed on the help usage. Check invoke_from_option for more information.
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.
class GemGenerator < Thor::Group class_option :test_framework, :type => :string invoke_from_option :test_framework end
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.
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 task.
You can also supply a block to customize how the option is giong to be invoked. The block receives two parameters, an instance of the current class and the klass to be invoked.
Start works differently in Thor::Group, it simply invokes all tasks inside the class.