Class: Dry::Schema::Message::Or::MultiPath
- Defined in:
- lib/dry/schema/message/or/multi_path.rb,
lib/dry/schema/extensions/hints.rb
Overview
A message type used by OR operations with different paths
Instance Attribute Summary collapse
- #root ⇒ Object readonly private
Attributes inherited from Abstract
Instance Method Summary collapse
- #hint? ⇒ Boolean private
-
#initialize ⇒ MultiPath
constructor
private
A new instance of MultiPath.
- #to_h ⇒ Object
Constructor Details
#initialize ⇒ MultiPath
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 MultiPath.
20 21 22 23 24 25 26 27 |
# File 'lib/dry/schema/message/or/multi_path.rb', line 20 def initialize(...) super flat_left = left.flatten flat_right = right.flatten @root = [*flat_left, *flat_right].map(&:_path).reduce(:&) @left = flat_left.map { _1.to_or(root) } @right = flat_right.map { _1.to_or(root) } end |
Instance Attribute Details
#root ⇒ 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/multi_path.rb', line 17 def root @root end |
Instance Method Details
#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.
35 36 37 |
# File 'lib/dry/schema/extensions/hints.rb', line 35 def hint? false end |
#to_h ⇒ Object
30 31 32 33 34 |
# File 'lib/dry/schema/message/or/multi_path.rb', line 30 def to_h @to_h ||= Path[[*root, :or]].to_h( [MessageSet.new(left).to_h, MessageSet.new(right).to_h] ) end |