Class: Mona::Result::Dict
- Inherits:
-
Object
- Object
- Mona::Result::Dict
- Defined in:
- lib/mona/result/dict.rb
Overview
Represents a dictionary of results, it is successful if all results are successful, and a failure if one is a failure. A Result::Dict can only contain one failure.
Defined Under Namespace
Modules: ReadInterface Classes: Err, OK
Constant Summary collapse
- EMPTY =
OK.new({}).freeze
Class Method Summary collapse
-
.new(initial = {}, &block) ⇒ Object
factory method that returns Dict::Success or Dict::Failure.
Class Method Details
.new(initial = {}, &block) ⇒ Object
factory method that returns Dict::Success or Dict::Failure
9 10 11 12 13 14 |
# File 'lib/mona/result/dict.rb', line 9 def self.new(initial = {}, &block) result = Dict::EMPTY initial.each { |k, v| result = result.set(k, v) } result = result.sequence(&block) if block result end |