lib/avro/schema.rb in avro-1.8.1 vs lib/avro/schema.rb in avro-1.8.2

- old
+ new

@@ -209,11 +209,11 @@ field_objects, field_names = [], Set.new field_data.each_with_index do |field, i| if field.respond_to?(:[]) # TODO(jmhodges) wtffffff type = field['type'] name = field['name'] - default = field['default'] + default = field.key?('default') ? field['default'] : :no_default order = field['order'] new_field = Field.new(type, name, default, order, names, namespace) # make sure field name has not been used yet if field_names.include?(new_field.name) raise SchemaParseError, "Field name #{new_field.name.inspect} is already in use" @@ -361,19 +361,19 @@ end class Field < Schema attr_reader :type, :name, :default, :order - def initialize(type, name, default=nil, order=nil, names=nil, namespace=nil) + def initialize(type, name, default=:no_default, order=nil, names=nil, namespace=nil) @type = subparse(type, names, namespace) @name = name @default = default @order = order end def to_avro(names=Set.new) {'name' => name, 'type' => type.to_avro(names)}.tap do |avro| - avro['default'] = default if default + avro['default'] = default unless default == :no_default avro['order'] = order if order end end end end