avromatic 0.28.1 → 0.29.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/avromatic/model/raw_serialization.rb +19 -7
- data/lib/avromatic/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ffb68968240ce157b9aeb4fd3e54dc2af726380
|
4
|
+
data.tar.gz: f205fd7e2877419fc07cff8293e32bbb589aa71c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c3eb099c2c4b382b84bd5784fa1b02c0a6b682979b1a95490b6ab762ec516174b2309a7332f67b47c26b60a97771fc3a63fc8994f2822fe96b30d42eff1f003
|
7
|
+
data.tar.gz: 555bbf5724310f0bd2c78fb815dfd7b1e820b053eedda6ff4ff17ed36264ab9065364a365b39e60fd1ba57609355ee9ed28057158a33c9f5cb490236514d7b43
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# avromatic changelog
|
2
2
|
|
3
|
+
## v0.29.0
|
4
|
+
- Add new public methods `#avro_key_datum` and `#avro_value_datum` on an
|
5
|
+
Avromatic model instance that return the attributes of the model suitable for
|
6
|
+
Avro encoding without any customizations.
|
7
|
+
|
3
8
|
## v0.28.1
|
4
9
|
- Fix a bug that raised an error when encoding a cached model containing optional
|
5
10
|
field(s). With this change, immutable model caching now enabled only when
|
@@ -22,13 +22,13 @@ module Avromatic
|
|
22
22
|
end
|
23
23
|
|
24
24
|
module ClassMethods
|
25
|
-
def recursive_serialize(value, name: nil, member_types: nil)
|
25
|
+
def recursive_serialize(value, name: nil, member_types: nil, strict: false)
|
26
26
|
member_types = attribute_member_types(name) if name
|
27
27
|
member_types ||= EMPTY_ARRAY
|
28
28
|
|
29
29
|
if value.is_a?(Avromatic::Model::Attributes)
|
30
|
-
hash = value.value_attributes_for_avro
|
31
|
-
if Avromatic.use_custom_datum_writer
|
30
|
+
hash = strict ? value.avro_value_datum : value.value_attributes_for_avro
|
31
|
+
if !strict && Avromatic.use_custom_datum_writer
|
32
32
|
if Avromatic.use_encoding_providers? && !value.class.config.mutable
|
33
33
|
# n.b. Ideally we'd just return value here instead of wrapping it in a
|
34
34
|
# hash but then we'd have no place to stash the union member index...
|
@@ -39,10 +39,10 @@ module Avromatic
|
|
39
39
|
end
|
40
40
|
hash
|
41
41
|
elsif value.is_a?(Array)
|
42
|
-
value.map { |v| recursive_serialize(v, member_types: member_types) }
|
42
|
+
value.map { |v| recursive_serialize(v, member_types: member_types, strict: strict) }
|
43
43
|
elsif value.is_a?(Hash)
|
44
44
|
value.each_with_object({}) do |(k, v), map|
|
45
|
-
map[k] = recursive_serialize(v, member_types: member_types)
|
45
|
+
map[k] = recursive_serialize(v, member_types: member_types, strict: strict)
|
46
46
|
end
|
47
47
|
else
|
48
48
|
avro_serializer[name].call(value)
|
@@ -96,11 +96,23 @@ module Avromatic
|
|
96
96
|
avro_hash(key_avro_field_names)
|
97
97
|
end
|
98
98
|
|
99
|
+
def avro_value_datum
|
100
|
+
if self.class.config.mutable
|
101
|
+
avro_hash(value_avro_field_names, strict: true)
|
102
|
+
else
|
103
|
+
@avro_datum ||= avro_hash(value_avro_field_names, strict: true)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def avro_key_datum
|
108
|
+
avro_hash(key_avro_field_names, strict: true)
|
109
|
+
end
|
110
|
+
|
99
111
|
private
|
100
112
|
|
101
|
-
def avro_hash(fields)
|
113
|
+
def avro_hash(fields, strict: false)
|
102
114
|
attributes.slice(*fields).each_with_object(Hash.new) do |(key, value), result|
|
103
|
-
result[key.to_s] = self.class.recursive_serialize(value, name: key)
|
115
|
+
result[key.to_s] = self.class.recursive_serialize(value, name: key, strict: strict)
|
104
116
|
end
|
105
117
|
end
|
106
118
|
|
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.29.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-
|
11
|
+
date: 2017-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: avro
|
@@ -330,7 +330,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
330
330
|
version: '0'
|
331
331
|
requirements: []
|
332
332
|
rubyforge_project:
|
333
|
-
rubygems_version: 2.6.
|
333
|
+
rubygems_version: 2.6.13
|
334
334
|
signing_key:
|
335
335
|
specification_version: 4
|
336
336
|
summary: Generate Ruby models from Avro schemas
|