Class: ProcessExecuter::Options::OptionDefinition
- Inherits:
-
Object
- Object
- ProcessExecuter::Options::OptionDefinition
- Defined in:
- lib/process_executer/options/option_definition.rb
Overview
Defines an option that can be used by an Options object
Instance Attribute Summary collapse
-
#default ⇒ Object
readonly
The default value of the option.
-
#name ⇒ Symbol
readonly
The name of the option.
-
#validator ⇒ Method, ...
readonly
A method or proc that validates the option.
Instance Method Summary collapse
-
#initialize(name, default: nil, validator: nil) ⇒ OptionDefinition
constructor
Create a new option definition.
Constructor Details
#initialize(name, default: nil, validator: nil) ⇒ OptionDefinition
Create a new option definition
53 54 55 56 57 |
# File 'lib/process_executer/options/option_definition.rb', line 53 def initialize(name, default: nil, validator: nil) @name = name @default = default @validator = validator end |
Instance Attribute Details
#default ⇒ Object (readonly)
The default value of the option
28 29 30 |
# File 'lib/process_executer/options/option_definition.rb', line 28 def default @default end |
#name ⇒ Symbol (readonly)
The name of the option
18 19 20 |
# File 'lib/process_executer/options/option_definition.rb', line 18 def name @name end |
#validator ⇒ Method, ... (readonly)
A method or proc that validates the option
A callable that receives option_key
, option_value
and is executed in the
context of the options instance. It should add messages to an errors
array
if validation fails.
44 45 46 |
# File 'lib/process_executer/options/option_definition.rb', line 44 def validator @validator end |