Sha256: 2955732307cbdd8e3b8164bb16a89efe367e41c76a13cab11efc5768195b0d53
Contents?: true
Size: 1.5 KB
Versions: 28
Compression:
Stored size: 1.5 KB
Contents
class AvroTurf module AvroGemPatch module RecordSchema module ClassMethods def make_field_objects(field_data, names, namespace=nil) new_field_data = [] field_data.each do |field| if field.respond_to?(:[]) && !field.key?('default') field = field.clone field['default'] = :no_default end new_field_data << field end super(new_field_data, names, namespace) end end def self.prepended(base) class << base prepend ClassMethods end end end module Field def initialize(type, name, default=:no_default, order=nil, names=nil, namespace=nil) super(type, name, default, order, names, namespace) end def to_avro(names=Set.new) {'name' => name, 'type' => type.to_avro(names)}.tap do |avro| avro['default'] = default unless default == :no_default avro['order'] = order if order end end end module DatumReader def read_default_value(field_schema, default_value) if default_value == :no_default raise Avro::AvroError, "Missing data for #{field_schema} with no default" end super end end end end Avro::Schema::RecordSchema.send(:prepend, AvroTurf::AvroGemPatch::RecordSchema) Avro::Schema::Field.send(:prepend, AvroTurf::AvroGemPatch::Field) Avro::IO::DatumReader.send(:prepend, AvroTurf::AvroGemPatch::DatumReader)
Version data entries
28 entries across 28 versions & 2 rubygems