Sha256: e1a4794bbc8f537063c0310582149cf892e24523751d9ae1ff82c8dcd6709b8b

Contents?: true

Size: 545 Bytes

Versions: 6

Compression:

Stored size: 545 Bytes

Contents

# frozen_string_literal: true

require "dry/logic/operations/binary"
require "dry/logic/result"

module Dry
  module Logic
    module Operations
      class Xor < Binary
        def type
          :xor
        end
        alias_method :operator, :type

        def call(input)
          Result.new(self[input], id) { ast(input) }
        end

        def [](input)
          left[input] ^ right[input]
        end

        def ast(input = Undefined)
          [type, rules.map { |rule| rule.ast(input) }]
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
dry-logic-1.2.0 lib/dry/logic/operations/xor.rb
dry-logic-1.1.1 lib/dry/logic/operations/xor.rb
dry-logic-1.1.0 lib/dry/logic/operations/xor.rb
dry-logic-1.0.8 lib/dry/logic/operations/xor.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/dry-logic-1.0.7/lib/dry/logic/operations/xor.rb
dry-logic-1.0.7 lib/dry/logic/operations/xor.rb