Class: Flags::ClassValidator
- Inherits:
-
FlagValidator
- Object
- FlagValidator
- Flags::ClassValidator
- Defined in:
- lib/flags.rb
Overview
A validator that raises an error if the class of the flag’s value is not one of the expected classes.
Instance Method Summary collapse
-
#initialize(*expected_value_classes) ⇒ ClassValidator
constructor
A new instance of ClassValidator.
Methods inherited from FlagValidator
Constructor Details
#initialize(*expected_value_classes) ⇒ ClassValidator
Returns a new instance of ClassValidator.
376 377 378 379 380 381 |
# File 'lib/flags.rb', line 376 def initialize(*expected_value_classes) expected_value_classes = expected_value_classes.to_a.flatten proc = Proc.new { |flag_value| expected_value_classes.include?(flag_value.class) } = "unexpected value class, expecting one of [#{expected_value_classes.join(',')}]" super(proc, ) end |