class StrongJSON::Type::ErrorPath

Attributes

parent[R]

@dynamic type, parent

type[R]

@dynamic type, parent

Public Class Methods

new(type:, parent:) click to toggle source
# File lib/strong_json/type.rb, line 405
def initialize(type:, parent:)
  @type = type
  @parent = parent
end
root(type) click to toggle source
# File lib/strong_json/type.rb, line 422
def self.root(type)
  self.new(type: type, parent: nil)
end

Public Instance Methods

dig(key:, type:) click to toggle source
# File lib/strong_json/type.rb, line 410
def dig(key:, type:)
  # @type var parent: [Integer | Symbol | nil, ErrorPath]
  parent = [key, self]
  self.class.new(type: type, parent: parent)
end
expand(type:) click to toggle source
# File lib/strong_json/type.rb, line 416
def expand(type:)
  # @type var parent: [Integer | Symbol | nil, ErrorPath]
  parent = [nil, self]
  self.class.new(type: type, parent: parent)
end
root?() click to toggle source
# File lib/strong_json/type.rb, line 426
def root?
  !parent
end
to_s() click to toggle source
# File lib/strong_json/type.rb, line 430
def to_s
  if pa = parent
    if key = pa[0]
      pa[1].to_s + case key
                   when Integer
                     "[#{key}]"
                   when Symbol
                     ".#{key}"
                   end
    else
      pa[1].to_s
    end
  else
    "$"
  end
end