Class: Flags::AllowedValuesValidator
- Inherits:
-
FlagValidator
- Object
- FlagValidator
- Flags::AllowedValuesValidator
- Defined in:
- lib/flags.rb
Overview
A validator that raises an error if the flag’s value is not in the provided set of allowed values.
Instance Method Summary collapse
-
#initialize(*allowed_values) ⇒ AllowedValuesValidator
constructor
A new instance of AllowedValuesValidator.
Methods inherited from FlagValidator
Constructor Details
#initialize(*allowed_values) ⇒ AllowedValuesValidator
Returns a new instance of AllowedValuesValidator.
396 397 398 399 400 401 |
# File 'lib/flags.rb', line 396 def initialize(*allowed_values) allowed_values = allowed_values.to_a.flatten proc = Proc.new { |flag_value| allowed_values.include?(flag_value) } = "illegal value, expecting one of [#{allowed_values.join(',')}]" super(proc, ) end |