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

Inherits:
Abstract
  • Object
show all
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

Attributes inherited from Abstract

#left, #right

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ 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
# File 'lib/dry/schema/message/or/multi_path.rb', line 20

def initialize(*args)
  super
  @root = [left, right].flatten.map(&:_path).reduce(:&)
  @left = left.map { |msg| msg.to_or(root) }
  @right = right.map { |msg| msg.to_or(root) }
end

Instance Attribute Details

#rootObject (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.

Returns:

  • (Boolean)


34
35
36
# File 'lib/dry/schema/extensions/hints.rb', line 34

def hint?
  false
end

#to_hObject



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

def to_h
  @to_h ||= Path[[*root, :or]].to_h(
    [left.map(&:to_h).reduce(:merge), right.map(&:to_h).reduce(:merge)]
  )
end