Class: Mona::DictResult::OK
- Includes:
- Mona::DictResult
- Defined in:
- lib/mona/dict_result/ok.rb
Overview
OK DictResult
Constant Summary
Constants included from Mona::DictResult
Constants included from Result
Instance Attribute Summary
Attributes inherited from OK
Instance Method Summary collapse
Methods included from Mona::DictResult
Methods included from Result
#==, [], #and_tap, #and_then, #deconstruct, #deconstruct_keys, #either, #err, #err?, #ok, #ok?, #or_else, #value_or
Methods inherited from OK
[], #either, #initialize, #inspect
Constructor Details
This class inherits a constructor from Mona::OK
Instance Method Details
#set(key, val) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/mona/dict_result/ok.rb', line 9 def set(key, val) key, failure_key = key if key.is_a?(Array) failure_key ||= key # @type var meta: Hash[Symbol, untyped] Result[val].either \ ->(value) { OK.new to_h.merge(key => value) }, ->(failure, reason, **) { Err.new to_h.merge(failure_key => failure), reason, **, key: failure_key } end |
#to_h ⇒ Object
19 |
# File 'lib/mona/dict_result/ok.rb', line 19 def to_h = @value |