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

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/validation/rule.rb

Direct Known Subclasses

Conjunction, Disjunction

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(left, right) ⇒ Composite

Returns a new instance of Composite.



37
38
39
40
41
# File 'lib/dry/validation/rule.rb', line 37

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

Instance Attribute Details

#leftObject (readonly)

Returns the value of attribute left.



35
36
37
# File 'lib/dry/validation/rule.rb', line 35

def left
  @left
end

#nameObject (readonly)

Returns the value of attribute name.



35
36
37
# File 'lib/dry/validation/rule.rb', line 35

def name
  @name
end

#rightObject (readonly)

Returns the value of attribute right.



35
36
37
# File 'lib/dry/validation/rule.rb', line 35

def right
  @right
end

Instance Method Details

#to_aryObject Also known as: to_a



43
44
45
# File 'lib/dry/validation/rule.rb', line 43

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