1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
# frozen_string_literal: true
require "dry/logic/operations/binary"
require "dry/logic/result"
module Dry
module Logic
module Operations
class Implication < Binary
def type
:implication
end
def operator
:then
end
def call(input)
left_result = left.(input)
if left_result.success?
right_result = right.(input)
Result.new(right_result.success?, id) { right_result.to_ast }
else
Result::SUCCESS
end
end
def [](input)
if left[input]
right[input]
else
true
end
end
end
end
end
end
|