Class: Optionable::Validator
- Inherits:
-
Object
- Object
- Optionable::Validator
- Defined in:
- lib/optionable/validator.rb
Overview
This is responsible for the actual validation of the options.
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#allow(*values) ⇒ Array<Object>
Tells the validator what values are acceptable for the option.
-
#initialize(key) ⇒ Validator
constructor
Initialize the new validator.
-
#validate!(value) ⇒ Object
Validate the provided value against the acceptable values.
Constructor Details
#initialize(key) ⇒ Validator
Initialize the new validator.
35 36 37 |
# File 'lib/optionable/validator.rb', line 35 def initialize(key) @key = key end |
Instance Attribute Details
#key ⇒ Object
11 12 13 |
# File 'lib/optionable/validator.rb', line 11 def key @key end |
Instance Method Details
#allow(*values) ⇒ Array<Object>
Tells the validator what values are acceptable for the option.
23 24 25 |
# File 'lib/optionable/validator.rb', line 23 def allow(*values) allowed_values.concat(values) end |