Class: Mona::Result::Dict

Inherits:
Object
  • Object
show all
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.

Since:

  • 0.1.0

Defined Under Namespace

Modules: ReadInterface Classes: Err, OK

Constant Summary collapse

EMPTY =

Since:

  • 0.1.0

OK.new({}).freeze

Class Method Summary collapse

Class Method Details

.new(initial = {}, &block) ⇒ Object

factory method that returns Dict::Success or Dict::Failure

Since:

  • 0.1.0



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