Class: RailsAppGenerator::BuildOption
- Inherits:
-
Object
- Object
- RailsAppGenerator::BuildOption
- Defined in:
- lib/rails_app_generator/options/build_option.rb
Overview
Option for the rails generator
This class maps closely (but not exactly) to Thor’s options The pattern is not exactly the same, it is easy to map the options you need from other generators such as: railties/lib/rails/generators/app_base.rb
Instance Attribute Summary collapse
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#mapper ⇒ Object
readonly
Returns the value of attribute mapper.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#required ⇒ Object
readonly
Returns the value of attribute required.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #cmd_option(value) ⇒ Object
-
#initialize(name, **args) ⇒ BuildOption
constructor
A new instance of BuildOption.
- #to_h ⇒ Object
Constructor Details
#initialize(name, **args) ⇒ BuildOption
Returns a new instance of BuildOption.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rails_app_generator/options/build_option.rb', line 12 def initialize(name, **args) @name = name @description = args[:description] || '' @type = args[:type] || :string @required = args.fetch(:required, false) @default = args[:default] || sane_default @mapper = args[:mapper] || sane_mapper raise ArgumentError, ':required should not be nil' if @required.nil? end |
Instance Attribute Details
#default ⇒ Object (readonly)
Returns the value of attribute default.
10 11 12 |
# File 'lib/rails_app_generator/options/build_option.rb', line 10 def default @default end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
10 11 12 |
# File 'lib/rails_app_generator/options/build_option.rb', line 10 def description @description end |
#mapper ⇒ Object (readonly)
Returns the value of attribute mapper.
10 11 12 |
# File 'lib/rails_app_generator/options/build_option.rb', line 10 def mapper @mapper end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/rails_app_generator/options/build_option.rb', line 10 def name @name end |
#required ⇒ Object (readonly)
Returns the value of attribute required.
10 11 12 |
# File 'lib/rails_app_generator/options/build_option.rb', line 10 def required @required end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
10 11 12 |
# File 'lib/rails_app_generator/options/build_option.rb', line 10 def type @type end |
Instance Method Details
#cmd_option(value) ⇒ Object
23 |
# File 'lib/rails_app_generator/options/build_option.rb', line 23 def cmd_option(value); end |
#to_h ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/rails_app_generator/options/build_option.rb', line 25 def to_h { name: name, description: description, type: type, default: default, required: required } end |