### Home Classes Methods

### In Files

- lib/padrino-gen/generators/actions.rb

### Methods

- #available_choices_for
- #component_option
- #component_types
- #defines_component_options
- #require_arguments!
- #require_arguments?

### Files

- README.rdoc
- README.rdoc

### Class/Module Index

Quicksearch

- Padrino
- Padrino::Generators
- Padrino::Generators::Actions
- Padrino::Generators::Actions::ClassMethods
- Padrino::Generators::App
- Padrino::Generators::AppRootNotFound
- Padrino::Generators::Cli
- Padrino::Generators::Component
- Padrino::Generators::Components
- Padrino::Generators::Components::Actions
- Padrino::Generators::Controller
- Padrino::Generators::Mailer
- Padrino::Generators::Migration
- Padrino::Generators::Model
- Padrino::Generators::Plugin
- Padrino::Generators::Project
- Padrino::Generators::Runner
- Padrino::Generators::SqlHelpers
- Padrino::Generators::Task
- ActiveRecord
- ActiveRecord::Schema
- Object

No matching classes.

# Padrino::Generators::Actions::ClassMethods

Class methods for Thor generators to support the generators and component choices.

### Public Instance Methods

available_choices_for(component) click to toggle source

Returns the list of available choices for the given component (including none).

@param [Symbol] component

    The type of the component module.

@return [Array<Symbol>] Array of component choices.

@example

    available_choices_for :test
    => [:shoulda, :bacon, :riot, :minitest]

    # File lib/padrino-gen/generators/actions.rb, line 571
    def available_choices_for(component)
      @available_choices[component] + [:none]
    end

component_option(name, caption, options = {}) click to toggle source

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.

@param [Symbol] name

    Name of component.

@param [String] caption

    Description of the component.

@param [Hash] options

    Additional parameters for component choice.

@example

    component_option :test, "Testing framework", :aliases => '-t', :choices => [:bacon, :shoulda]

    # File lib/padrino-gen/generators/actions.rb, line 514
    def component_option(name, caption, options = {})
      (@component_types   ||= []) << name # TODO use ordered hash and combine with choices below
      (@available_choices ||= Hash.new)[name] = options[:choices]
      description = "The #{caption} component (#{options[:choices].join(', ')}, none)"
      class_option name, :default => options[:default] || options[:choices].first, :aliases => options[:aliases], :desc => description
    end

component_types() click to toggle source

Returns the compiled list of component types which can be specified.

    # File lib/padrino-gen/generators/actions.rb, line 555
    def component_types
      @component_types
    end

defines_component_options(options = {}) click to toggle source

Definitions for the available customizable components.

    # File lib/padrino-gen/generators/actions.rb, line 524
    def defines_component_options(options = {})
      [
        [ :orm,        'database engine',    { :aliases => '-d', :default => :none }],
        [ :test,       'testing framework',  { :aliases => '-t', :default => :none }],
        [ :mock,       'mocking library',    { :aliases => '-m', :default => :none }],
        [ :script,     'javascript library', { :aliases => '-s', :default => :none }],
        [ :renderer,   'template engine',    { :aliases => '-e', :default => :slim }],
        [ :stylesheet, 'stylesheet engine',  { :aliases => '-c', :default => :none }]
      ].each do |name, caption, opts|
        opts[:default] = '' if options[:default] == false
        component_option name, caption, opts.merge(:choices => Dir["#{File.dirname(__FILE__)}/components/#{name.to_s.pluralize}/*.rb"].map{|lib| File.basename(lib, '.rb').to_sym})
      end
    end

require_arguments!() click to toggle source

Tell Padrino that for this Thor::Group it is a necessary task to run.

    # File lib/padrino-gen/generators/actions.rb, line 541
    def require_arguments!
      @require_arguments = true
    end

require_arguments?() click to toggle source

Return true if we need an arguments for our Thor::Group.

    # File lib/padrino-gen/generators/actions.rb, line 548
    def require_arguments?
      @require_arguments
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.