Sha256: 55a8d91249b7506ca29375a4654232307ed0749a8a2671f9fbba9349c690ac7d

Contents?: true

Size: 689 Bytes

Versions: 7

Compression:

Stored size: 689 Bytes

Contents

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

7 entries across 7 versions & 1 rubygems

Version Path
dry-logic-1.0.0 lib/dry/logic/operations/implication.rb
dry-logic-0.6.1 lib/dry/logic/operations/implication.rb
dry-logic-0.6.0 lib/dry/logic/operations/implication.rb
dry-logic-0.5.0 lib/dry/logic/operations/implication.rb
dry-logic-0.4.2 lib/dry/logic/operations/implication.rb
dry-logic-0.4.1 lib/dry/logic/operations/implication.rb
dry-logic-0.4.0 lib/dry/logic/operations/implication.rb