Class: Definition::KeyConformError

Inherits:
ConformError show all
Defined in:
lib/definition/key_conform_error.rb

Instance Attribute Summary collapse

Attributes inherited from ConformError

#definition, #i18n_context, #i18n_key, #message, #parent, #sub_errors, #translated_error

Instance Method Summary collapse

Methods inherited from ConformError

#error_path, #json_pointer, #leaf_errors, #to_s

Constructor Details

#initialize(definition, message, key:, sub_errors: [], **options) ⇒ KeyConformError

Returns a new instance of KeyConformError.



7
8
9
10
# File 'lib/definition/key_conform_error.rb', line 7

def initialize(definition, message, key:, sub_errors: [], **options)
  self.key = key
  super(definition, message, sub_errors: sub_errors, **options)
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



12
13
14
# File 'lib/definition/key_conform_error.rb', line 12

def key
  @key
end

Instance Method Details

#error_key_pathObject



14
15
16
17
18
19
20
21
22
# File 'lib/definition/key_conform_error.rb', line 14

def error_key_path
  path = [key]
  while (current = parent)
    next unless current.is_a?(KeyConformError)

    path += [current.key]
  end
  path.reverse
end