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.
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/dry/validation/message.rb', line 54 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.
8 9 10 |
# File 'lib/dry/validation/message.rb', line 8 def args @args end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/dry/validation/message.rb', line 8 def @options end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/dry/validation/message.rb', line 8 def path @path end |
#predicate ⇒ Object (readonly)
Returns the value of attribute predicate.
8 9 10 |
# File 'lib/dry/validation/message.rb', line 8 def predicate @predicate end |
#rule ⇒ Object (readonly)
Returns the value of attribute rule.
8 9 10 |
# File 'lib/dry/validation/message.rb', line 8 def rule @rule end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
8 9 10 |
# File 'lib/dry/validation/message.rb', line 8 def text @text end |
Class Method Details
Instance Method Details
#eql?(other) ⇒ Boolean
83 84 85 |
# File 'lib/dry/validation/message.rb', line 83 def eql?(other) other.is_a?(String) ? text == other : super end |
#hint? ⇒ Boolean
75 76 77 |
# File 'lib/dry/validation/message.rb', line 75 def hint? false end |
#root? ⇒ Boolean
79 80 81 |
# File 'lib/dry/validation/message.rb', line 79 def root? path.empty? end |
#signature ⇒ Object
71 72 73 |
# File 'lib/dry/validation/message.rb', line 71 def signature @signature ||= [predicate, args, path].hash end |
#to_s ⇒ Object
67 68 69 |
# File 'lib/dry/validation/message.rb', line 67 def to_s text end |