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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 00b29e492064bce7661c64f961e168ebeeee1f4d
4
- data.tar.gz: 1fed6c7b78a6000d67b85c279c0a2522af3fc0a2
3
+ metadata.gz: 0006753e54e4ba4a3b0a5f40fa71810417d1b37f
4
+ data.tar.gz: 00da3685e121175995d6908a76c23ff0997108fc
5
5
  SHA512:
6
- metadata.gz: 86395a7cd21081d58234433a33c91f8f9291e49a672d625a1a45f19c0b9ca096e5afdc0c72a23357c5eefa790cf1b378b54adde8e5c95c1109e78e650ef3e898
7
- data.tar.gz: 0af78d4a8423308c37faedd6d7baec82950eb19202944adc1beed97300bd838e42233df7d21e87864f6febd6ead44f751b236be686f0fb053e9bf3bbcdc0c9ee
6
+ metadata.gz: fc9f465e19cb10d935fe191acdb21ad51eb4aa1e9dbe373355672048b32a81b71c2c61afde243c6ac22e6b14a6b33e3b52f6b16350504cf2026a3edebefc9f34
7
+ data.tar.gz: 6d3acedd8f81a97b065a27d684c95367fa841f3ec78f0e295dc6672e770ddef77cdc9189baa4ddfceb38977bf6d59c266c4fa4d9a65d2db302bc51a49374458a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # avromatic changelog
2
2
 
3
+ ## v0.23.0
4
+ - Add mutable option when defining a model.
5
+
3
6
  ## v0.22.0
4
7
  - Require `avro_schema_registry_client` v0.3.0 or later to avoid
5
8
  using `avro-salsify-fork`.
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. `Virtus` attributes are added for each field in the Avro schema
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
 
@@ -42,7 +42,7 @@ module Avromatic
42
42
  def inclusions
43
43
  [
44
44
  ActiveModel::Validations,
45
- Virtus.value_object,
45
+ config.mutable ? Virtus.model : Virtus.value_object,
46
46
  Avromatic::Model::Configurable,
47
47
  Avromatic::Model::NestedModels,
48
48
  Avromatic::Model::Validation,
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Avromatic
2
- VERSION = '0.22.0'.freeze
2
+ VERSION = '0.23.0'.freeze
3
3
  end
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.22.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-01 00:00:00.000000000 Z
11
+ date: 2017-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avro