Method: Puer::Generators::Actions::ClassMethods#component_option

Defined in:
lib/puer/generators/actions.rb

#component_option(name, caption, options = {}) ⇒ Object

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 component_option :test, “Testing framework”, :aliases => ‘-t’, :choices => [:bacon, :shoulda]



154
155
156
157
158
159
# File 'lib/puer/generators/actions.rb', line 154

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