Class: Cliqr::Config::OptionBased Private
- Inherits:
-
Named
- Object
- Base
- EventBased
- Named
- Cliqr::Config::OptionBased
- Defined in:
- lib/cliqr/config/option_based.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Configuration setting for an option based setting
Instance Attribute Summary collapse
-
#options ⇒ Array<OptionConfig>
private
Array of options applied to the base command.
Attributes inherited from Named
Attributes inherited from EventBased
Instance Method Summary collapse
-
#finalize ⇒ Cliqr::Config::OptionBased
private
Finalize config by adding default values for unset values.
-
#initialize ⇒ OptionBased
constructor
private
New config instance with all attributes set as UNSET.
-
#option(name) ⇒ String
private
Get value of a option.
-
#option?(name) ⇒ Boolean
private
Check if particular option is set.
-
#options? ⇒ Boolean
private
Check if options are set.
-
#set_config(name, value, *args, &block) ⇒ Cliqr::Config::Option
private
Set value for a config option.
Methods inherited from Named
Methods inherited from EventBased
Methods inherited from Base
Methods included from Validation
#errors, included, #read_attributes, #valid?, #validate, #validations
Methods included from DSL
Constructor Details
#initialize ⇒ OptionBased
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.
New config instance with all attributes set as UNSET
22 23 24 25 26 27 |
# File 'lib/cliqr/config/option_based.rb', line 22 def initialize super = {} @short_option_index = {} end |
Instance Attribute Details
#options ⇒ Array<OptionConfig>
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.
Array of options applied to the base command
17 18 19 |
# File 'lib/cliqr/config/option_based.rb', line 17 def end |
Instance Method Details
#finalize ⇒ Cliqr::Config::OptionBased
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.
Finalize config by adding default values for unset values
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/cliqr/config/option_based.rb', line 32 def finalize super if && @short_option_index.empty? .values.each do |option| @short_option_index[option.short.to_s] = option if option.short? end end self end |
#option(name) ⇒ String
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.
Get value of a option
78 79 80 81 82 83 84 |
# File 'lib/cliqr/config/option_based.rb', line 78 def option(name) if .key?(name.to_s) [name.to_s] else @short_option_index[name.to_s] end end |
#option?(name) ⇒ Boolean
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.
Check if particular option is set
69 70 71 |
# File 'lib/cliqr/config/option_based.rb', line 69 def option?(name) .key?(name.to_s) || @short_option_index.key?(name.to_s) end |
#options? ⇒ Boolean
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.
Check if options are set
61 62 63 64 |
# File 'lib/cliqr/config/option_based.rb', line 61 def return false if .nil? !.empty? end |
#set_config(name, value, *args, &block) ⇒ Cliqr::Config::Option
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.
Set value for a config option
51 52 53 54 55 56 57 58 |
# File 'lib/cliqr/config/option_based.rb', line 51 def set_config(name, value, *args, &block) case name when :option handle_option(value, &block) # value is the long name for the option else super end end |