Exception: DynamicSchema::IncompatibleTypeError

Inherits:
Error
  • Object
show all
Defined in:
lib/dynamic_schema/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path: nil, key:, type:, value:) ⇒ IncompatibleTypeError

Returns a new instance of IncompatibleTypeError.



11
12
13
14
15
16
17
18
# File 'lib/dynamic_schema/errors.rb', line 11

def initialize( path: nil, key:, type:, value: )
  path = path ? path.to_s.chomp( '/' ) : nil 
  @key = key
  @keypath = path ? ( path + '/' + @key.to_s ) : @key.to_s 
  @type = type
  type_text = @type.respond_to?( :join ) ? type.join( ', ' ) : type
  super( "The attribute '#{@keypath}' expects '#{type_text}' but incompatible '#{value.class.name}' was given." )
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



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

def key
  @key
end

#keypathObject (readonly)

Returns the value of attribute keypath.



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

def keypath
  @keypath
end

#typeObject (readonly)

Returns the value of attribute type.



9
10
11
# File 'lib/dynamic_schema/errors.rb', line 9

def type
  @type
end