Module: Avromatic::Model::Attributes
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/avromatic/model/attributes.rb
Overview
This module supports defining Virtus attributes for a model based on the fields of Avro schemas.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Class Method Details
.first_union_schema(field_type) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/avromatic/model/attributes.rb', line 12 def self.first_union_schema(field_type) # TODO: This is a hack until I find a better solution for unions with # Virtus. This only handles a union for an optional field with :null # and one other type. # This hack lives on for now because custom type coercion is not pushed # down into unions. This means that custom types can only be optional # fields, not members of real unions. field_type.schemas.reject { |schema| schema.type_sym == :null }.first end |