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

Defined Under Namespace

Classes: MessageArray

Constant Summary collapse

MESSAGE_ARRAY_HANDLER =
-> { MessageArray.new(_1) }

Instance Attribute Summary

Attributes inherited from Abstract

#left, #right

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Abstract

#initialize

Constructor Details

This class inherits a constructor from Dry::Schema::Message::Or::Abstract

Class Method Details

.handler(message) ⇒ 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.



37
38
39
40
41
42
43
44
# File 'lib/dry/schema/message/or/multi_path.rb', line 37

def self.handler(message)
  case message
  when self
    IDENTITY
  when Array
    MESSAGE_ARRAY_HANDLER
  end
end

Instance Method Details

#_pathObject

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.



67
68
69
# File 'lib/dry/schema/message/or/multi_path.rb', line 67

def _path
  @_path ||= Path[root]
end

#_pathsObject

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.



72
73
74
# File 'lib/dry/schema/message/or/multi_path.rb', line 72

def _paths
  @paths ||= _messages.flat_map(&:_paths)
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)


31
32
33
# File 'lib/dry/schema/extensions/hints.rb', line 31

def hint?
  false
end

#messagesObject

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.



52
53
54
# File 'lib/dry/schema/message/or/multi_path.rb', line 52

def messages
  @messages ||= _messages.flat_map { _1.to_or(root) }
end

#pathObject

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.



62
63
64
# File 'lib/dry/schema/message/or/multi_path.rb', line 62

def path
  root
end

#rootObject

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/multi_path.rb', line 57

def root
  @root ||= _paths.reduce(:&)
end

#to_hObject



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

def to_h
  @to_h ||= Path[[*root, :or]].to_h(messages.map(&:to_h))
end

#to_or(root) ⇒ 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.



77
78
79
# File 'lib/dry/schema/message/or/multi_path.rb', line 77

def to_or(root)
  self.root == root ? messages : [self]
end