Exception: StrongJSON::Type::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/strong_json/type.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, type:, value:) ⇒ Error

Returns a new instance of Error.



260
261
262
263
264
# File 'lib/strong_json/type.rb', line 260

def initialize(path:, type:, value:)
  @path = path
  @type = type
  @value = value
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



258
259
260
# File 'lib/strong_json/type.rb', line 258

def path
  @path
end

#typeObject (readonly)

Returns the value of attribute type.



258
259
260
# File 'lib/strong_json/type.rb', line 258

def type
  @type
end

#valueObject (readonly)

Returns the value of attribute value.



258
259
260
# File 'lib/strong_json/type.rb', line 258

def value
  @value
end

Instance Method Details

#to_sObject



266
267
268
269
# File 'lib/strong_json/type.rb', line 266

def to_s
  position = path.empty? ? "" : " at .#{path.join('.')}"
  "Expected type of value #{value}#{position} is #{type}"
end