Exception: DynamicSchema::IncompatibleTypeError
- Defined in:
- lib/dynamic_schema/errors.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#keypath ⇒ Object
readonly
Returns the value of attribute keypath.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(path: nil, key:, type:, value:) ⇒ IncompatibleTypeError
constructor
A new instance of IncompatibleTypeError.
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
#key ⇒ Object (readonly)
Returns the value of attribute key.
8 9 10 |
# File 'lib/dynamic_schema/errors.rb', line 8 def key @key end |
#keypath ⇒ Object (readonly)
Returns the value of attribute keypath.
7 8 9 |
# File 'lib/dynamic_schema/errors.rb', line 7 def keypath @keypath end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/dynamic_schema/errors.rb', line 9 def type @type end |