Class: Dry::Schema::Message::Or

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/schema/message/or.rb,
lib/dry/schema/extensions/hints.rb

Overview

Hints extension for Or messages

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(left, right, messages) ⇒ Or

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Or.



28
29
30
31
32
33
# File 'lib/dry/schema/message/or.rb', line 28

def initialize(left, right, messages)
  @left = left
  @right = right
  @messages = messages
  @path = left.path
end

Instance Attribute Details

#leftObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



16
17
18
# File 'lib/dry/schema/message/or.rb', line 16

def left
  @left
end

#messagesObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



25
26
27
# File 'lib/dry/schema/message/or.rb', line 25

def messages
  @messages
end

#pathObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



22
23
24
# File 'lib/dry/schema/message/or.rb', line 22

def path
  @path
end

#rightObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



19
20
21
# File 'lib/dry/schema/message/or.rb', line 19

def right
  @right
end

Instance Method Details

#dumpString Also known as: to_s

Dump a message into a string

Returns:

  • (String)

See Also:



42
43
44
# File 'lib/dry/schema/message/or.rb', line 42

def dump
  to_a.map(&:dump).join(" #{messages[:or][:text]} ")
end

#hint?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


27
28
29
# File 'lib/dry/schema/extensions/hints.rb', line 27

def hint?
  false
end

#to_aObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



48
49
50
# File 'lib/dry/schema/message/or.rb', line 48

def to_a
  [left, right]
end