README.md in avro-builder-0.11.0 vs README.md in avro-builder-0.12.0
- old
+ new
@@ -183,10 +183,20 @@
required :array_of_unions, :array, items: union(:int, :string)
required :array_or_map, :union, types: [array(:int), map(:int)]
end
```
+Methods may also be used for complex types instead of separately specifying the
+type name and options:
+
+```ruby
+record :complex_types do
+ required :array_of_unions, array(union(:int, :string))
+ required :array_or_map, union(array(:int), map(:int))
+end
+```
+
For more on unions see [below](#unions).
### Nested Records
Nested records may be created by referring to the name of the previously
@@ -251,9 +261,19 @@
end
```
For an optional union, `null` is automatically added as the first type for
the union and the field defaults to `null`.
+
+Unions may also be defined using the `union` method instead of specifying the
+`:union` type and member types separately:
+
+```ruby
+record :my_record_with_unions do
+ required :req_union, union(:string, :int)
+ optional :opt_union, union(:float, :long)
+end
+```
### Logical Types
The DSL supports setting a logical type on any type except a union. The logical
types defined in the Avro [spec](https://avro.apache.org/docs/1.8.1/spec.html#Logical+Types)