class Avromatic::Model::Types::DecimalType
Constants
- INPUT_CLASSES
- VALUE_CLASSES
Attributes
Public Class Methods
Source
# File lib/avromatic/model/types/decimal_type.rb, line 16 def initialize(precision:, scale: 0) super() @precision = precision @scale = scale end
Calls superclass method
Public Instance Methods
Source
# File lib/avromatic/model/types/decimal_type.rb, line 34 def coerce(input) case input when ::NilClass, ::BigDecimal input when ::Float, ::Integer input.to_d else raise ArgumentError.new("Could not coerce '#{input.inspect}' to #{name}") end end
Source
# File lib/avromatic/model/types/decimal_type.rb, line 26 def input_classes INPUT_CLASSES end
Source
# File lib/avromatic/model/types/decimal_type.rb, line 30 def name "decimal(#{precision}, #{scale})" end
Source
# File lib/avromatic/model/types/decimal_type.rb, line 49 def referenced_model_classes EMPTY_ARRAY end
Source
# File lib/avromatic/model/types/decimal_type.rb, line 45 def serialize(value, _strict) value end
Source
# File lib/avromatic/model/types/decimal_type.rb, line 22 def value_classes VALUE_CLASSES end