Sha256: f485ec71cbe89e52383a67efaa3885104637fea70643a09d1a5582a9cd1f53c1

Contents?: true

Size: 720 Bytes

Versions: 5

Compression:

Stored size: 720 Bytes

Contents

# 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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dry-logic-1.0.6 lib/dry/logic/operations/implication.rb
dry-logic-1.0.5 lib/dry/logic/operations/implication.rb
dry-logic-1.0.4 lib/dry/logic/operations/implication.rb
dry-logic-1.0.3 lib/dry/logic/operations/implication.rb
dry-logic-1.0.2 lib/dry/logic/operations/implication.rb