Sha256: 6eae4d1547bee8060255b4f1ac061c96588af4ccbd8feaeea9eb8a57b1ed1b82

Contents?: true

Size: 682 Bytes

Versions: 4

Compression:

Stored size: 682 Bytes

Contents

# frozen_string_literal: true

module Dry
  module Logic
    module Operations
      class Or < Binary
        def type
          :or
        end
        alias_method :operator, :type

        def call(input)
          left_result = left.(input)

          if left_result.success?
            Result::SUCCESS
          else
            right_result = right.(input)

            if right_result.success?
              Result::SUCCESS
            else
              Result.new(false, id) { [:or, [left_result.to_ast, right_result.to_ast]] }
            end
          end
        end

        def [](input)
          left[input] || right[input]
        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/or.rb
dry-logic-1.5.0 lib/dry/logic/operations/or.rb
dry-logic-1.4.0 lib/dry/logic/operations/or.rb
dry-logic-1.3.0 lib/dry/logic/operations/or.rb