Class: StrongJSON::Type::ErrorPath
- Inherits:
-
Object
- Object
- StrongJSON::Type::ErrorPath
- Defined in:
- lib/strong_json/type.rb
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #dig(key:, type:) ⇒ Object
- #expand(type:) ⇒ Object
-
#initialize(type:, parent:) ⇒ ErrorPath
constructor
A new instance of ErrorPath.
- #root? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(type:, parent:) ⇒ ErrorPath
Returns a new instance of ErrorPath.
412 413 414 415 |
# File 'lib/strong_json/type.rb', line 412 def initialize(type:, parent:) @type = type @parent = parent end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
410 411 412 |
# File 'lib/strong_json/type.rb', line 410 def parent @parent end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
410 411 412 |
# File 'lib/strong_json/type.rb', line 410 def type @type end |
Class Method Details
Instance Method Details
#dig(key:, type:) ⇒ Object
417 418 419 420 421 |
# File 'lib/strong_json/type.rb', line 417 def dig(key:, type:) # @type var parent: [Integer | Symbol | nil, ErrorPath] parent = [key, self] self.class.new(type: type, parent: parent) end |
#expand(type:) ⇒ Object
423 424 425 426 427 |
# File 'lib/strong_json/type.rb', line 423 def (type:) # @type var parent: [Integer | Symbol | nil, ErrorPath] parent = [nil, self] self.class.new(type: type, parent: parent) end |
#root? ⇒ Boolean
433 434 435 |
# File 'lib/strong_json/type.rb', line 433 def root? !parent end |
#to_s ⇒ Object
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 |
# File 'lib/strong_json/type.rb', line 437 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 |