Class: Kleisli::Contracts::MaybeOf
- Defined in:
- lib/kleisli/contracts.rb
Instance Method Summary collapse
Methods inherited from KContract
Constructor Details
This class inherits a constructor from Kleisli::Contracts::KContract
Instance Method Details
#valid?(val) ⇒ Boolean
21 22 23 24 25 26 |
# File 'lib/kleisli/contracts.rb', line 21 def valid?(val) return false unless val.kind_of?(Kleisli::Maybe) && @inner_types.size == 1 inner_valid, _ = Contract.valid?(val.value, @inner_types.first) inner_valid || val.value.nil? end |