Module: Padrino::Generators::Actions::ClassMethods
- Defined in:
- padrino-gen/lib/padrino-gen/generators/actions.rb
Overview
Class methods for Thor generators to support the generators and component choices.
Instance Method Summary (collapse)
-
- (Array<Symbol>) available_choices_for(component)
Returns the list of available choices for the given component (including none).
-
- (Object) component_option(name, caption, options = {})
private
Defines a class option to allow a component to be chosen and add to component type list Also builds the available_choices hash of which component choices are supported.
-
- (Object) component_types
private
Returns the compiled list of component types which can be specified.
-
- (Object) require_arguments!
private
Tell padrino that for this Thor::Group it is a necessary task to run.
-
- (Boolean) require_arguments?
private
Return true if we need an arguments for our Thor::Group.
Instance Method Details
- (Array<Symbol>) available_choices_for(component)
Returns the list of available choices for the given component (including none)
511 512 513 |
# File 'padrino-gen/lib/padrino-gen/generators/actions.rb', line 511 def available_choices_for(component) @available_choices[component] + [:none] end |
- (Object) component_option(name, caption, options = {})
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Defines a class option to allow a component to be chosen and add to component type list Also builds the available_choices hash of which component choices are supported
471 472 473 474 475 476 |
# File 'padrino-gen/lib/padrino-gen/generators/actions.rb', line 471 def component_option(name, caption, = {}) (@component_types ||= []) << name # TODO use ordered hash and combine with choices below (@available_choices ||= Hash.new)[name] = [:choices] description = "The #{caption} component (#{options[:choices].join(', ')}, none)" class_option name, :default => [:default] || [:choices].first, :aliases => [:aliases], :desc => description end |
- (Object) component_types
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the compiled list of component types which can be specified
495 496 497 |
# File 'padrino-gen/lib/padrino-gen/generators/actions.rb', line 495 def component_types @component_types end |
- (Object) require_arguments!
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Tell padrino that for this Thor::Group it is a necessary task to run
481 482 483 |
# File 'padrino-gen/lib/padrino-gen/generators/actions.rb', line 481 def require_arguments! @require_arguments = true end |
- (Boolean) require_arguments?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return true if we need an arguments for our Thor::Group
488 489 490 |
# File 'padrino-gen/lib/padrino-gen/generators/actions.rb', line 488 def require_arguments? @require_arguments end |