Class: Dry::Schema::Message
- Inherits:
-
Object
- Object
- Dry::Schema::Message
- Defined in:
- lib/dry/schema/message.rb,
lib/dry/schema/extensions/hints.rb
Overview
Hint-specific Message extensions
Direct Known Subclasses
Defined Under Namespace
Classes: Or
Instance Attribute Summary collapse
- #args ⇒ Object readonly
- #options ⇒ Object readonly
- #path ⇒ Object readonly
- #predicate ⇒ Object readonly
- #text ⇒ Object readonly
Class Method Summary collapse
-
.[](predicate, path, text, options) ⇒ Object
private
Build a new message object.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #eql?(other) ⇒ Boolean private
- #hint? ⇒ Boolean private
-
#initialize(predicate, path, text, options) ⇒ Message
constructor
private
A new instance of Message.
-
#to_s ⇒ Object
Return a string representation of the message.
Constructor Details
#initialize(predicate, path, text, options) ⇒ Message
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 Message.
68 69 70 71 72 73 74 |
# File 'lib/dry/schema/message.rb', line 68 def initialize(predicate, path, text, ) @predicate = predicate @path = path @text = text @options = @args = [:args] || EMPTY_ARRAY end |
Instance Attribute Details
#args ⇒ Object (readonly)
14 15 16 |
# File 'lib/dry/schema/message.rb', line 14 def args @args end |
#options ⇒ Object (readonly)
14 15 16 |
# File 'lib/dry/schema/message.rb', line 14 def @options end |
#path ⇒ Object (readonly)
14 15 16 |
# File 'lib/dry/schema/message.rb', line 14 def path @path end |
#predicate ⇒ Object (readonly)
14 15 16 |
# File 'lib/dry/schema/message.rb', line 14 def predicate @predicate end |
#text ⇒ Object (readonly)
14 15 16 |
# File 'lib/dry/schema/message.rb', line 14 def text @text end |
Class Method Details
.[](predicate, path, text, options) ⇒ 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.
Build a new message object
63 64 65 |
# File 'lib/dry/schema/message.rb', line 63 def self.[](predicate, path, text, ) Message.new(predicate, path, text, ) end |
Instance Method Details
#<=>(other) ⇒ Object
88 89 90 91 92 93 94 95 96 97 |
# File 'lib/dry/schema/message.rb', line 88 def <=>(other) l_path = Path[path] r_path = Path[other.path] unless l_path.include?(r_path) raise ArgumentError, 'Cannot compare messages from different root paths' end l_path <=> r_path end |
#eql?(other) ⇒ 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.
84 85 86 |
# File 'lib/dry/schema/message.rb', line 84 def eql?(other) other.is_a?(String) ? text == other : super 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.
29 30 31 |
# File 'lib/dry/schema/extensions/hints.rb', line 29 def hint? false end |
#to_s ⇒ Object
Return a string representation of the message
79 80 81 |
# File 'lib/dry/schema/message.rb', line 79 def to_s text end |