Class: Dry::Validation::Rule::Composite

Inherits:
Dry::Validation::Rule show all
Defined in:
lib/dry/validation/rule/composite.rb

Direct Known Subclasses

Conjunction, Disjunction, Implication

Instance Attribute Summary collapse

Attributes inherited from Dry::Validation::Rule

#predicate

Instance Method Summary collapse

Methods inherited from Dry::Validation::Rule

#and, #curry, #or, #then

Constructor Details

#initialize(left, right) ⇒ Composite

Returns a new instance of Composite.



8
9
10
11
12
# File 'lib/dry/validation/rule/composite.rb', line 8

def initialize(left, right)
  @name = left.name
  @left = left
  @right = right
end

Instance Attribute Details

#leftObject (readonly)

Returns the value of attribute left.



6
7
8
# File 'lib/dry/validation/rule/composite.rb', line 6

def left
  @left
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/dry/validation/rule/composite.rb', line 6

def name
  @name
end

#rightObject (readonly)

Returns the value of attribute right.



6
7
8
# File 'lib/dry/validation/rule/composite.rb', line 6

def right
  @right
end

Instance Method Details

#to_aryObject Also known as: to_a



14
15
16
# File 'lib/dry/validation/rule/composite.rb', line 14

def to_ary
  [type, [left.to_ary, right.to_ary]]
end