README.md in avromatic-4.0.0 vs README.md in avromatic-4.1.0
- old
+ new
@@ -122,11 +122,11 @@
The Avro schema can be specified by name and loaded using the schema store:
```ruby
class MyModel
- include Avromatic::Model.build(schema_name :my_model)
+ include Avromatic::Model.build(schema_name: :my_model)
end
# Construct instances by passing in a hash of attributes
instance = MyModel.new(id: 123, name: 'Tesla Model 3', enabled: true)
@@ -154,16 +154,24 @@
class MyModel
include Avromatic::Model.build(schema: schema_object)
end
```
+A specific subject name can be associated with the schema:
+```ruby
+class MyModel
+ include Avromatic::Model.build(schema_name: 'my_model',
+ schema_subject: 'my_model-value')
+end
+```
+
Models are generated as immutable value
objects by default, but can optionally be defined as mutable:
```ruby
class MyModel
- include Avromatic::Model.build(schema_name :my_model, mutable: true)
+ include Avromatic::Model.build(schema_name: :my_model, mutable: true)
end
```
Generated models include attributes for each field in the Avro schema
including any default values defined in the schema.
@@ -190,9 +198,19 @@
```ruby
class MyTopic
include Avromatic::Model.build(value_schema_name: :topic_value,
key_schema_name: :topic_key,
allow_optional_key_fields: true)
+end
+```
+
+A specific subject name can be associated with both the value and key schemas:
+```ruby
+class MyTopic
+ include Avromatic::Model.build(value_schema_name: :topic_value,
+ value_schema_subject: 'topic_value-value',
+ key_schema_name: :topic_key,
+ key_schema_subject: 'topic_key-value')
end
```
A model can also be generated as an anonymous class that can be assigned to a
constant: