Class: Avromatic::Model::Types::AbstractType

Inherits:
Object
  • Object
show all
Defined in:
lib/avromatic/model/types/abstract_type.rb

Instance Method Summary collapse

Instance Method Details

#coerce(_input) ⇒ Object



23
24
25
# File 'lib/avromatic/model/types/abstract_type.rb', line 23

def coerce(_input)
  raise "#{__method__} must be overridden by #{self.class.name}"
end

#coerced?(value) ⇒ Boolean

Returns:

  • (Boolean)


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

def coerced?(value)
  value.nil? || value_classes.any? { |value_class| value.is_a?(value_class) }
end

#coercible?(input) ⇒ Boolean

Returns:

  • (Boolean)


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

def coercible?(input)
  input.nil? || input_classes.any? { |input_class| input.is_a?(input_class) }
end

#input_classesObject



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

def input_classes
  value_classes
end

#nameObject



19
20
21
# File 'lib/avromatic/model/types/abstract_type.rb', line 19

def name
  raise "#{__method__} must be overridden by #{self.class.name}"
end

#referenced_model_classesObject



41
42
43
# File 'lib/avromatic/model/types/abstract_type.rb', line 41

def referenced_model_classes
  raise "#{__method__} must be overridden by #{self.class.name}"
end

#serialize(_value, _strict) ⇒ Object

Note we use positional args rather than keyword args to reduce memory allocations



37
38
39
# File 'lib/avromatic/model/types/abstract_type.rb', line 37

def serialize(_value, _strict)
  raise "#{__method__} must be overridden by #{self.class.name}"
end

#value_classesObject



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

def value_classes
  raise "#{__method__} must be overridden by #{self.class.name}"
end