Class: Dry::Validation::Message
- Inherits:
-
Object
- Object
- Dry::Validation::Message
- Includes:
- Core::Constants
- 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.
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/dry/validation/message.rb', line 55 def initialize(predicate, path, text, ) @predicate = predicate @path = path @text = text = @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.
9 10 11 |
# File 'lib/dry/validation/message.rb', line 9 def args @args end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/dry/validation/message.rb', line 9 def end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/dry/validation/message.rb', line 9 def path @path end |
#predicate ⇒ Object (readonly)
Returns the value of attribute predicate.
9 10 11 |
# File 'lib/dry/validation/message.rb', line 9 def predicate @predicate end |
#rule ⇒ Object (readonly)
Returns the value of attribute rule.
9 10 11 |
# File 'lib/dry/validation/message.rb', line 9 def rule @rule end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
9 10 11 |
# File 'lib/dry/validation/message.rb', line 9 def text @text end |
Class Method Details
.[](predicate, path, text, options) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/dry/validation/message.rb', line 47 def self.[](predicate, path, text, ) if [:check] Message::Check.new(predicate, path, text, ) else Message.new(predicate, path, text, ) end end |
Instance Method Details
#eql?(other) ⇒ Boolean
84 85 86 |
# File 'lib/dry/validation/message.rb', line 84 def eql?(other) other.is_a?(String) ? text == other : super end |
#hint? ⇒ Boolean
76 77 78 |
# File 'lib/dry/validation/message.rb', line 76 def hint? false end |
#root? ⇒ Boolean
80 81 82 |
# File 'lib/dry/validation/message.rb', line 80 def root? path.empty? end |
#signature ⇒ Object
72 73 74 |
# File 'lib/dry/validation/message.rb', line 72 def signature @signature ||= [predicate, args, path].hash end |
#to_s ⇒ Object
68 69 70 |
# File 'lib/dry/validation/message.rb', line 68 def to_s text end |