Class: Dry::Logic::Rule::ExclusiveDisjunction

Inherits:
Composite show all
Defined in:
lib/dry/logic/rule/composite.rb

Instance Attribute Summary

Attributes inherited from Composite

#left, #right

Attributes inherited from Dry::Logic::Rule

#options, #predicate

Instance Method Summary collapse

Methods inherited from Composite

#initialize, #name, #to_ast

Methods inherited from Dry::Logic::Rule

#and, #curry, #each?, #initialize, #negation, #new, #or, #predicate_id, #then, #xor

Constructor Details

This class inherits a constructor from Dry::Logic::Rule::Composite

Instance Method Details

#call(input) ⇒ Object



70
71
72
# File 'lib/dry/logic/rule/composite.rb', line 70

def call(input)
  Logic.Result(left.(input).success? ^ right.(input).success?, self, input)
end

#evaluate(input) ⇒ Object



74
75
76
# File 'lib/dry/logic/rule/composite.rb', line 74

def evaluate(input)
  [left.evaluate(input), right.evaluate(input)]
end

#typeObject



78
79
80
# File 'lib/dry/logic/rule/composite.rb', line 78

def type
  :xor
end