Class: Mona::Result::Dict::OK
- Includes:
- ReadInterface
- Defined in:
- lib/mona/result/dict.rb
Overview
OK dict result
Instance Attribute Summary
Attributes inherited from OK
Instance Method Summary collapse
Methods included from ReadInterface
Methods inherited from OK
#and_tap, #and_then, #deconstruct, #deconstruct_keys, #either, #err, #err?, #initialize, #ok, #ok?, #or_else, #to_result, #to_s, #value_or
Constructor Details
This class inherits a constructor from Mona::Result::OK
Instance Method Details
#sequence ⇒ Object
38 |
# File 'lib/mona/result/dict.rb', line 38 def sequence(&) = Sequence.new(self).call(&) |
#set(key, to_result) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/mona/result/dict.rb', line 29 def set(key, to_result) key, failure_key = key if key.is_a?(Array) failure_key ||= key Result[to_result].either \ ->(value) { OK.new to_h.merge(key => value) }, ->(failure, reason, **m) { Err.new to_h.merge(failure_key => failure), reason, **m, key: failure_key } end |
#to_h ⇒ Object
40 |
# File 'lib/mona/result/dict.rb', line 40 def to_h = @value |