Class: Avromatic::Model::Types::BooleanType

Inherits:
AbstractType show all
Defined in:
lib/avromatic/model/types/boolean_type.rb

Constant Summary collapse

VALUE_CLASSES =
[::TrueClass, ::FalseClass].freeze

Instance Method Summary collapse

Methods inherited from AbstractType

#coerced?, #coercible?, #input_classes

Instance Method Details

#coerce(input) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/avromatic/model/types/boolean_type.rb', line 19

def coerce(input)
  if coercible?(input)
    input
  else
    raise ArgumentError.new("Could not coerce '#{input.inspect}' to #{name}")
  end
end

#nameObject



15
16
17
# File 'lib/avromatic/model/types/boolean_type.rb', line 15

def name
  'boolean'
end

#referenced_model_classesObject



31
32
33
# File 'lib/avromatic/model/types/boolean_type.rb', line 31

def referenced_model_classes
  EMPTY_ARRAY
end

#serialize(value, _strict) ⇒ Object



27
28
29
# File 'lib/avromatic/model/types/boolean_type.rb', line 27

def serialize(value, _strict)
  value
end

#value_classesObject



11
12
13
# File 'lib/avromatic/model/types/boolean_type.rb', line 11

def value_classes
  VALUE_CLASSES
end