Sha256: 71088522d971c95762c31f88330de744b8473f58ff8e1bd1e4e5e84735aa0ce8

Contents?: true

Size: 654 Bytes

Versions: 4

Compression:

Stored size: 654 Bytes

Contents

# frozen_string_literal: true

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

4 entries across 4 versions & 1 rubygems

Version Path
dry-logic-1.6.0 lib/dry/logic/operations/implication.rb
dry-logic-1.5.0 lib/dry/logic/operations/implication.rb
dry-logic-1.4.0 lib/dry/logic/operations/implication.rb
dry-logic-1.3.0 lib/dry/logic/operations/implication.rb