class Dry::Schema::Message

Hint-specific Message extensions

@see Message

@api public

Message objects used by message sets

@api public

Message objects used by message sets

@api public

Public Instance Methods

<=>(other) click to toggle source

See which message is higher in the hierarchy

@api private

# File lib/dry/schema/message.rb, line 96
def <=>(other)
  l_path = _path
  r_path = other._path

  unless l_path.same_root?(r_path)
    raise ArgumentError, "Cannot compare messages from different root paths"
  end

  l_path <=> r_path
end
_path() click to toggle source

@api private

# File lib/dry/schema/message.rb, line 108
def _path
  @_path ||= Path[path]
end
dump() click to toggle source

Dump the message to a representation suitable for the message set hash

@return [String,Hash]

@api public

# File lib/dry/schema/message.rb, line 54
def dump
  @dump ||= meta.empty? ? text : {text: text, **meta}
end
Also aliased as: to_s
eql?(other) click to toggle source

See if another message is the same

If a string is passed, it will be compared with the text

@param other [Message,String]

@return [Boolean]

@api private

Calls superclass method
# File lib/dry/schema/message.rb, line 81
def eql?(other)
  other.is_a?(String) ? text == other : super
end
hint?() click to toggle source

@api private

# File lib/dry/schema/extensions/hints.rb, line 42
def hint?
  false
end
to_h() click to toggle source

Dump the message into a hash

The hash will be deeply nested if the path's size is greater than 1

@see Message#to_h

@return [Hash]

@api public

# File lib/dry/schema/message.rb, line 68
def to_h
  @to_h ||= _path.to_h(dump)
end
to_or(root) click to toggle source

@api private

# File lib/dry/schema/message.rb, line 86
def to_or(root)
  clone = dup
  clone.instance_variable_set("@path", path - root.to_a)
  clone.instance_variable_set("@_path", nil)
  clone
end
to_s()
Alias for: dump