Class: Dry::Validation::Message
- Inherits:
-
Object
- Object
- Dry::Validation::Message
- Defined in:
- lib/dry/validation/message.rb
Defined Under Namespace
Classes: Each
Constant Summary collapse
- Index =
Class.new { def inspect "index" end alias_method :to_s, :inspect }.new
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#path ⇒ Object
(also: #index_path)
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
- #each? ⇒ Boolean
- #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.
32 33 34 35 36 37 38 39 40 |
# File 'lib/dry/validation/message.rb', line 32 def initialize(predicate, path, text, ) @predicate = predicate @path = path @text = text @options = @rule = [:rule] @each = [:each] || false @args = [:args] || EMPTY_ARRAY end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
15 16 17 |
# File 'lib/dry/validation/message.rb', line 15 def args @args end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
15 16 17 |
# File 'lib/dry/validation/message.rb', line 15 def @options end |
#path ⇒ Object (readonly) Also known as: index_path
Returns the value of attribute path.
15 16 17 |
# File 'lib/dry/validation/message.rb', line 15 def path @path end |
#predicate ⇒ Object (readonly)
Returns the value of attribute predicate.
15 16 17 |
# File 'lib/dry/validation/message.rb', line 15 def predicate @predicate end |
#rule ⇒ Object (readonly)
Returns the value of attribute rule.
15 16 17 |
# File 'lib/dry/validation/message.rb', line 15 def rule @rule end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
15 16 17 |
# File 'lib/dry/validation/message.rb', line 15 def text @text end |
Class Method Details
Instance Method Details
#each? ⇒ Boolean
52 53 54 |
# File 'lib/dry/validation/message.rb', line 52 def each? @each end |
#eql?(other) ⇒ Boolean
64 65 66 |
# File 'lib/dry/validation/message.rb', line 64 def eql?(other) other.is_a?(String) ? text == other : super end |
#hint? ⇒ Boolean
56 57 58 |
# File 'lib/dry/validation/message.rb', line 56 def hint? false end |
#root? ⇒ Boolean
60 61 62 |
# File 'lib/dry/validation/message.rb', line 60 def root? path.empty? end |
#signature ⇒ Object
48 49 50 |
# File 'lib/dry/validation/message.rb', line 48 def signature @signature ||= [predicate, args, index_path].hash end |
#to_s ⇒ Object
44 45 46 |
# File 'lib/dry/validation/message.rb', line 44 def to_s text end |