Sha256: ad9f3008fc60caf863aba17c1fe73e46071fb7e52592c6ef7c8a94b62fdbdafa
Contents?: true
Size: 1.05 KB
Versions: 2
Compression:
Stored size: 1.05 KB
Contents
module Dry module Logic class Rule::Composite < Rule include Dry::Equalizer(:left, :right) attr_reader :name, :left, :right def initialize(left, right) @left = left @right = right end def name :"#{left.name}_#{type}_#{right.name}" end def to_ary [type, [left.to_ary, right.to_ary]] end alias_method :to_a, :to_ary end class Rule::Implication < Rule::Composite def call(*args) left.(*args).then(right) end def type :implication end end class Rule::Conjunction < Rule::Composite def call(*args) left.(*args).and(right) end def type :and end end class Rule::Disjunction < Rule::Composite def call(*args) left.(*args).or(right) end def type :or end end class Rule::ExclusiveDisjunction < Rule::Composite def call(*args) left.(*args).xor(right) end def type :xor end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dry-logic-0.1.4 | lib/dry/logic/rule/composite.rb |
dry-logic-0.1.3 | lib/dry/logic/rule/composite.rb |