class Validate::Constraints::ValidationContext::Path
Public Class Methods
new(paths = [])
click to toggle source
# File lib/validate/constraints/validation_context.rb, line 99 def initialize(paths = []) @paths = paths end
Public Instance Methods
at(index)
click to toggle source
# File lib/validate/constraints/validation_context.rb, line 120 def at(index) raise Error::IndexError if index.negative? return nil if index.zero? @paths.fetch(index - 1) end
child(path)
click to toggle source
# File lib/validate/constraints/validation_context.rb, line 103 def child(path) case path when KeyPath, AttrPath Path.new(@paths.dup << path) when Path Path.new(@paths.dup << path.to_a) else raise ArgumentError, 'invalid path' end end
inspect()
click to toggle source
# File lib/validate/constraints/validation_context.rb, line 127 def inspect return "#<#{self.class.name} <root>>" if @paths.empty? "#<#{self.class.name} #{to_s}>" end
to_s()
click to toggle source
# File lib/validate/constraints/validation_context.rb, line 114 def to_s return '.' if @paths.empty? @paths.join end