Class: Dry::Schema::Message
- Inherits:
-
Object
- Object
- Dry::Schema::Message
- Extended by:
- Initializer
- Defined in:
- lib/dry/schema/message.rb,
lib/dry/schema/message/or.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 ⇒ Array
readonly
Optional list of arguments used by the predicate.
-
#input ⇒ Object
readonly
The input value.
-
#meta ⇒ Hash
readonly
Arbitrary meta data.
-
#path ⇒ String
readonly
Path to the value.
-
#predicate ⇒ Symbol
readonly
Predicate identifier that was used to produce a message.
-
#text ⇒ String
readonly
Message text representation created from a localized template.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
private
See which message is higher in the hierarchy.
-
#dump ⇒ String, Hash
(also: #to_s)
Dump the message to a representation suitable for the message set hash.
-
#eql?(other) ⇒ Boolean
private
See if another message is the same.
- #hint? ⇒ Boolean private
Instance Attribute Details
#args ⇒ Array (readonly)
Optional list of arguments used by the predicate
37 |
# File 'lib/dry/schema/message.rb', line 37 option :args, default: proc { EMPTY_ARRAY } |
#input ⇒ Object (readonly)
The input value
42 |
# File 'lib/dry/schema/message.rb', line 42 option :input |
#meta ⇒ Hash (readonly)
Arbitrary meta data
47 |
# File 'lib/dry/schema/message.rb', line 47 option :meta, optional: true, default: proc { EMPTY_HASH } |
#path ⇒ String (readonly)
Path to the value
27 |
# File 'lib/dry/schema/message.rb', line 27 option :path |
#predicate ⇒ Symbol (readonly)
Predicate identifier that was used to produce a message
32 |
# File 'lib/dry/schema/message.rb', line 32 option :predicate |
#text ⇒ String (readonly)
Message text representation created from a localized template
22 |
# File 'lib/dry/schema/message.rb', line 22 option :text |
Instance Method Details
#<=>(other) ⇒ 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.
See which message is higher in the hierarchy
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/dry/schema/message.rb', line 75 def <=>(other) l_path = Path[path] r_path = 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 |
#dump ⇒ String, Hash Also known as: to_s
Dump the message to a representation suitable for the message set hash
54 55 56 |
# File 'lib/dry/schema/message.rb', line 54 def dump @dump ||= .empty? ? text : { text: text, ** } 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.
See if another message is the same
If a string is passed, it will be compared with the text
68 69 70 |
# File 'lib/dry/schema/message.rb', line 68 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.
33 34 35 |
# File 'lib/dry/schema/extensions/hints.rb', line 33 def hint? false end |