Class: Dry::Validation::Message
- Inherits:
-
Object
- Object
- Dry::Validation::Message
- Defined in:
- lib/dry/validation/message.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#predicate ⇒ Object
readonly
Returns the value of attribute predicate.
-
#rule ⇒ Object
readonly
Returns the value of attribute rule.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean
- #hint? ⇒ Boolean
-
#initialize(predicate, path, text, options) ⇒ Message
constructor
A new instance of Message.
- #root? ⇒ Boolean
- #signature ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(predicate, path, text, options) ⇒ Message
Returns a new instance of Message.
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/dry/validation/message.rb', line 52 def initialize(predicate, path, text, ) @predicate = predicate @path = path @text = text @options = @rule = [:rule] @args = [:args] || EMPTY_ARRAY if predicate == :key? @path << rule end end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
6 7 8 |
# File 'lib/dry/validation/message.rb', line 6 def args @args end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/dry/validation/message.rb', line 6 def @options end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/dry/validation/message.rb', line 6 def path @path end |
#predicate ⇒ Object (readonly)
Returns the value of attribute predicate.
6 7 8 |
# File 'lib/dry/validation/message.rb', line 6 def predicate @predicate end |
#rule ⇒ Object (readonly)
Returns the value of attribute rule.
6 7 8 |
# File 'lib/dry/validation/message.rb', line 6 def rule @rule end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
6 7 8 |
# File 'lib/dry/validation/message.rb', line 6 def text @text end |
Class Method Details
Instance Method Details
#eql?(other) ⇒ Boolean
81 82 83 |
# File 'lib/dry/validation/message.rb', line 81 def eql?(other) other.is_a?(String) ? text == other : super end |
#hint? ⇒ Boolean
73 74 75 |
# File 'lib/dry/validation/message.rb', line 73 def hint? false end |
#root? ⇒ Boolean
77 78 79 |
# File 'lib/dry/validation/message.rb', line 77 def root? path.empty? end |
#signature ⇒ Object
69 70 71 |
# File 'lib/dry/validation/message.rb', line 69 def signature @signature ||= [predicate, args, path].hash end |
#to_s ⇒ Object
65 66 67 |
# File 'lib/dry/validation/message.rb', line 65 def to_s text end |