Class: RSchema::ErrorDetails

Inherits:
Struct
  • Object
show all
Defined in:
lib/rschema.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(failing_value, reason, key_path = []) ⇒ ErrorDetails

Returns a new instance of ErrorDetails.



8
9
10
# File 'lib/rschema.rb', line 8

def initialize(failing_value, reason, key_path = [])
  super(failing_value, reason, key_path)
end

Instance Attribute Details

#failing_valueObject

Returns the value of attribute failing_value

Returns:

  • (Object)

    the current value of failing_value



7
8
9
# File 'lib/rschema.rb', line 7

def failing_value
  @failing_value
end

#key_pathObject

Returns the value of attribute key_path

Returns:

  • (Object)

    the current value of key_path



7
8
9
# File 'lib/rschema.rb', line 7

def key_path
  @key_path
end

#reasonObject

Returns the value of attribute reason

Returns:

  • (Object)

    the current value of reason



7
8
9
# File 'lib/rschema.rb', line 7

def reason
  @reason
end

Instance Method Details

#extend_key_path(key) ⇒ Object



17
18
19
20
# File 'lib/rschema.rb', line 17

def extend_key_path(key)
  key_path.unshift(key)
  self
end

#to_sObject



12
13
14
15
# File 'lib/rschema.rb', line 12

def to_s
  prefix = (key_path.empty? ?  'The root value' : "The value at #{key_path.inspect}")
  "#{prefix} #{reason}: #{failing_value.inspect}"
end