Class: Mon::Contract::Try
- Inherits:
-
MonadContract
- Object
- Contracts::CallableClass
- MonadContract
- Mon::Contract::Try
- Defined in:
- lib/contracts/try.rb
Instance Method Summary collapse
Methods inherited from MonadContract
#initialize, #nested_contract, #to_s, #valid_nested_contract?
Constructor Details
This class inherits a constructor from Mon::Contract::MonadContract
Instance Method Details
#valid?(val) ⇒ Boolean
16 17 18 19 20 |
# File 'lib/contracts/try.rb', line 16 def valid?(val) # Should be a Try (i.e. success or failure), and if it's a # success, the value should be valid re: the provided contract val.is_a?(Mon::M::Try) and (val.is_a?(Mon::M::Success).implies(valid_nested_contract?(val._))) end |