Class: DearInventory::Validators::Enum
- Inherits:
-
DearInventory::Validator
- Object
- DearInventory::Validator
- DearInventory::Validators::Enum
- Extended by:
- T::Sig
- Defined in:
- lib/dear_inventory/validators/enum.rb
Instance Method Summary collapse
Methods inherited from DearInventory::Validator
Constructor Details
This class inherits a constructor from DearInventory::Validator
Instance Method Details
#call ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/dear_inventory/validators/enum.rb', line 10 def call value = instance_variable_get(:@value) return if value.nil? return if T.must(@values).include?(value) raise_error( "expected one of " \ "#{T.must(@values).map(&:inspect).join(", ")} " \ "but received #{value.inspect}" ) end |