avromatic 0.22.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +9 -1
- data/lib/avromatic/model/builder.rb +1 -1
- data/lib/avromatic/model/configuration.rb +3 -1
- data/lib/avromatic/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0006753e54e4ba4a3b0a5f40fa71810417d1b37f
|
4
|
+
data.tar.gz: 00da3685e121175995d6908a76c23ff0997108fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc9f465e19cb10d935fe191acdb21ad51eb4aa1e9dbe373355672048b32a81b71c2c61afde243c6ac22e6b14a6b33e3b52f6b16350504cf2026a3edebefc9f34
|
7
|
+
data.tar.gz: 6d3acedd8f81a97b065a27d684c95367fa841f3ec78f0e295dc6672e770ddef77cdc9189baa4ddfceb38977bf6d59c266c4fa4d9a65d2db302bc51a49374458a
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -118,7 +118,15 @@ end
|
|
118
118
|
```
|
119
119
|
|
120
120
|
Models are generated as [Virtus](https://github.com/solnic/virtus) value
|
121
|
-
objects
|
121
|
+
objects by default, but can optionally be defined as mutable:
|
122
|
+
|
123
|
+
```ruby
|
124
|
+
class MyModel
|
125
|
+
include Avromatic::Model.build(schema_name :my_model, mutable: true)
|
126
|
+
end
|
127
|
+
```
|
128
|
+
|
129
|
+
`Virtus` attributes are added for each field in the Avro schema
|
122
130
|
including any default values defined in the schema. `ActiveModel` validations
|
123
131
|
are used to define validations on certain types of fields ([see below](#validations)).
|
124
132
|
|
@@ -4,7 +4,7 @@ module Avromatic
|
|
4
4
|
# This class holds configuration for a model built from Avro schema(s).
|
5
5
|
class Configuration
|
6
6
|
|
7
|
-
attr_reader :avro_schema, :key_avro_schema, :nested_models
|
7
|
+
attr_reader :avro_schema, :key_avro_schema, :nested_models, :mutable
|
8
8
|
delegate :schema_store, to: Avromatic
|
9
9
|
|
10
10
|
# Either schema(_name) or value_schema(_name), but not both, must be
|
@@ -18,11 +18,13 @@ module Avromatic
|
|
18
18
|
# @option options [Avro::Schema] :key_schema
|
19
19
|
# @option options [String, Symbol] :key_schema_name
|
20
20
|
# @option options [Avromatic::ModelRegistry] :nested_models
|
21
|
+
# @option options [Boolean] :mutable, default false
|
21
22
|
def initialize(**options)
|
22
23
|
@avro_schema = find_avro_schema(**options)
|
23
24
|
raise ArgumentError.new('value_schema(_name) or schema(_name) must be specified') unless avro_schema
|
24
25
|
@key_avro_schema = find_schema_by_option(:key_schema, **options)
|
25
26
|
@nested_models = options[:nested_models]
|
27
|
+
@mutable = options.fetch(:mutable, false)
|
26
28
|
end
|
27
29
|
|
28
30
|
alias_method :value_avro_schema, :avro_schema
|
data/lib/avromatic/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avromatic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.23.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Salsify Engineering
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: avro
|