Class: Vop::CommandParam
- Inherits:
-
Object
- Object
- Vop::CommandParam
- Defined in:
- lib/vop/objects/command_param.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(name, options = {}) ⇒ CommandParam
constructor
A new instance of CommandParam.
-
#wants_context ⇒ Object
some params do not want to prefilled from the context.
Constructor Details
#initialize(name, options = {}) ⇒ CommandParam
Returns a new instance of CommandParam.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/vop/objects/command_param.rb', line 7 def initialize(name, = {}) @name = name unless .is_a? Hash raise "[CommandParam] sanity check failed: unexpected options object class #{.class}, expected Hash" end # auto-detect boolean parameters if .has_key? :default if [:default] == true || [:default] == false [:boolean] = true end end defaults = { multi: false, mandatory: false, default_param: false } @options = defaults.merge() end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/vop/objects/command_param.rb', line 5 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/vop/objects/command_param.rb', line 5 def @options end |
Instance Method Details
#wants_context ⇒ Object
some params do not want to prefilled from the context
30 31 32 33 34 35 |
# File 'lib/vop/objects/command_param.rb', line 30 def wants_context !( .has_key?(:use_context) && [:use_context] == false ) end |