Class: Dry::Validation::Schema::Definition::Rule

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Rule

Returns a new instance of Rule.



8
9
10
# File 'lib/dry/validation/schema/rule.rb', line 8

def initialize(node)
  @node = node
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



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

def node
  @node
end

Instance Method Details

#&(other) ⇒ Object



17
18
19
# File 'lib/dry/validation/schema/rule.rb', line 17

def &(other)
  self.class.new([:and, [node, other.to_ary]])
end

#to_aryObject Also known as: to_a



12
13
14
# File 'lib/dry/validation/schema/rule.rb', line 12

def to_ary
  node
end

#|(other) ⇒ Object



21
22
23
# File 'lib/dry/validation/schema/rule.rb', line 21

def |(other)
  self.class.new([:or, [node, other.to_ary]])
end