Class: Dry::Schema::Message::Or::SinglePath
- Defined in:
- lib/dry/schema/extensions/hints.rb,
lib/dry/schema/message/or/single_path.rb
Overview
A message type used by OR operations with the same path
Instance Attribute Summary collapse
- #_path ⇒ Object readonly private
- #messages ⇒ Object readonly private
- #path ⇒ Object readonly private
Attributes inherited from Abstract
Instance Method Summary collapse
-
#dump ⇒ String
(also: #to_s)
Dump a message into a string.
- #hint? ⇒ Boolean private
-
#initialize(*args, messages) ⇒ SinglePath
constructor
private
A new instance of SinglePath.
- #to_a ⇒ Object private
-
#to_h ⇒ String
Dump an `or` message into a hash.
Constructor Details
#initialize(*args, messages) ⇒ SinglePath
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 SinglePath.
23 24 25 26 27 28 |
# File 'lib/dry/schema/message/or/single_path.rb', line 23 def initialize(*args, ) super(*args) @messages = @path = left.path @_path = left._path end |
Instance Attribute Details
#_path ⇒ Object (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.
17 18 19 |
# File 'lib/dry/schema/message/or/single_path.rb', line 17 def _path @_path end |
#messages ⇒ Object (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.
20 21 22 |
# File 'lib/dry/schema/message/or/single_path.rb', line 20 def @messages end |
#path ⇒ Object (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.
14 15 16 |
# File 'lib/dry/schema/message/or/single_path.rb', line 14 def path @path end |
Instance Method Details
#dump ⇒ String Also known as: to_s
Dump a message into a string
Both sides of the message will be joined using translated value under `dry_schema.or` message key
40 41 42 |
# File 'lib/dry/schema/message/or/single_path.rb', line 40 def dump @dump ||= "#{left.dump} #{[:or]} #{right.dump}" 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.
27 28 29 |
# File 'lib/dry/schema/extensions/hints.rb', line 27 def hint? false end |
#to_a ⇒ Object
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.
57 58 59 |
# File 'lib/dry/schema/message/or/single_path.rb', line 57 def to_a @to_a ||= [left, right] end |
#to_h ⇒ String
Dump an `or` message into a hash
52 53 54 |
# File 'lib/dry/schema/message/or/single_path.rb', line 52 def to_h @to_h ||= _path.to_h(dump) end |