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
7 8 9 10 11 12 13 |
# File 'lib/dry/validation/message_compiler/visitor_opts.rb', line 7 def self.new opts = super opts[:path] = Core::Constants::EMPTY_ARRAY opts[:rule] = nil opts[:message_type] = :failure opts end |
Instance Method Details
#call(other) ⇒ Object
33 34 35 |
# File 'lib/dry/validation/message_compiler/visitor_opts.rb', line 33 def call(other) merge(other.update(path: [*path, *other[:path]])) end |
#path ⇒ Object
19 20 21 |
# File 'lib/dry/validation/message_compiler/visitor_opts.rb', line 19 def path self[:path] end |
#path? ⇒ Boolean
15 16 17 |
# File 'lib/dry/validation/message_compiler/visitor_opts.rb', line 15 def path? ! path.empty? end |
#rule ⇒ Object
23 24 25 |
# File 'lib/dry/validation/message_compiler/visitor_opts.rb', line 23 def rule self[:rule] end |
#with_rule(new_rule, **other) ⇒ Object
27 28 29 30 31 |
# File 'lib/dry/validation/message_compiler/visitor_opts.rb', line 27 def with_rule(new_rule, **other) opts = dup opts[:rule] = new_rule unless opts.rule opts.(other) end |