Class: Remap::Mapper::And

Inherits:
Binary show all
Defined in:
lib/remap/mapper/and.rb

Constant Summary

Constants included from State

State::Schema

Instance Method Summary collapse

Methods inherited from Binary

#exception

Methods included from Operation

#call

Methods included from State

#state

Methods included from Operations

#&, #^, #|

Instance Method Details

#call!(state, &error) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/remap/mapper/and.rb', line 8

def call!(state, &error)
  unless error
    return call!(state, &exception)
  end

  state1 = left.call!(state) do |failure1|
    right.call!(state) do |failure2|
      return error[failure1.merge(failure2)]
    end

    return error[failure1]
  end

  state2 = right.call!(state) do |failure|
    return error[failure]
  end

  state1.merged(state2)
end