Class: Dry::Validation::Schema::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.



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

def initialize(node)
  @node = node
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#nodeObject (readonly)

Returns the value of attribute node.



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

def node
  @node
end

Instance Method Details

#&(other) ⇒ Object



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

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

#to_aryObject Also known as: to_a



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

def to_ary
  node
end

#|(other) ⇒ Object



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

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