Class: Dry::Logic::Rule::Composite
- Inherits:
-
Dry::Logic::Rule
- Object
- Dry::Logic::Rule
- Dry::Logic::Rule::Composite
- Defined in:
- lib/dry/logic/rule/composite.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#left ⇒ Object
readonly
Returns the value of attribute left.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
Attributes inherited from Dry::Logic::Rule
Instance Method Summary collapse
-
#initialize(left, right) ⇒ Composite
constructor
A new instance of Composite.
- #name ⇒ Object
- #to_ast ⇒ Object (also: #to_a)
Methods inherited from Dry::Logic::Rule
#and, #curry, #each?, #negation, #new, #or, #predicate_id, #then, #type, #xor
Constructor Details
#initialize(left, right) ⇒ Composite
Returns a new instance of Composite.
8 9 10 11 |
# File 'lib/dry/logic/rule/composite.rb', line 8 def initialize(left, right) @left = left @right = right end |
Instance Attribute Details
#left ⇒ Object (readonly)
Returns the value of attribute left.
6 7 8 |
# File 'lib/dry/logic/rule/composite.rb', line 6 def left @left end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
6 7 8 |
# File 'lib/dry/logic/rule/composite.rb', line 6 def right @right end |
Instance Method Details
#name ⇒ Object
13 14 15 |
# File 'lib/dry/logic/rule/composite.rb', line 13 def name :"#{left.name}_#{type}_#{right.name}" end |
#to_ast ⇒ Object Also known as: to_a
17 18 19 |
# File 'lib/dry/logic/rule/composite.rb', line 17 def to_ast [type, [left.to_ast, right.to_ast]] end |