Class: Dry::Validation::MessageCompiler::VisitorOpts
- Inherits:
-
Hash
- Object
- Hash
- Dry::Validation::MessageCompiler::VisitorOpts
- Defined in:
- lib/dry/validation/message_compiler/visitor_opts.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call(other) ⇒ Object
- #path ⇒ Object
- #path? ⇒ Boolean
- #rule ⇒ Object
- #with_rule(new_rule, **other) ⇒ Object
Class Method Details
.new ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/dry/validation/message_compiler/visitor_opts.rb', line 5 def self.new opts = super opts[:path] = EMPTY_ARRAY opts[:rule] = nil opts[:message_type] = :failure opts end |
Instance Method Details
#call(other) ⇒ Object
31 32 33 |
# File 'lib/dry/validation/message_compiler/visitor_opts.rb', line 31 def call(other) merge(other.update(path: [*path, *other[:path]])) end |
#path ⇒ Object
17 18 19 |
# File 'lib/dry/validation/message_compiler/visitor_opts.rb', line 17 def path self[:path] end |
#path? ⇒ Boolean
13 14 15 |
# File 'lib/dry/validation/message_compiler/visitor_opts.rb', line 13 def path? ! path.empty? end |
#rule ⇒ Object
21 22 23 |
# File 'lib/dry/validation/message_compiler/visitor_opts.rb', line 21 def rule self[:rule] end |
#with_rule(new_rule, **other) ⇒ Object
25 26 27 28 29 |
# File 'lib/dry/validation/message_compiler/visitor_opts.rb', line 25 def with_rule(new_rule, **other) opts = dup opts[:rule] = new_rule unless opts.rule opts.(other) end |