deimos-ruby 2.0.16 → 2.1.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 +8 -0
- data/README.md +13 -2
- data/karafka.rb +1 -0
- data/lib/deimos/producer.rb +6 -1
- data/lib/deimos/schema_class/enum.rb +1 -1
- data/lib/deimos/schema_class/record.rb +19 -2
- data/lib/deimos/test_helpers.rb +18 -6
- data/lib/deimos/utils/schema_class.rb +1 -1
- data/lib/deimos/version.rb +1 -1
- data/lib/generators/deimos/schema_class/templates/schema_record.rb.tt +3 -2
- data/lib/generators/deimos/schema_class_generator.rb +3 -3
- data/spec/batch_consumer_spec.rb +14 -12
- data/spec/consumer_spec.rb +51 -5
- data/spec/schemas/my_namespace/generated.rb +2 -2
- data/spec/schemas/my_namespace/my_nested_schema.rb +2 -2
- data/spec/schemas/my_namespace/my_schema.rb +2 -2
- data/spec/schemas/my_namespace/my_schema_with_circular_reference.rb +1 -1
- data/spec/schemas/my_namespace/my_schema_with_complex_type.rb +9 -9
- data/spec/schemas/my_namespace/my_schema_with_union_type.rb +38 -23
- data/spec/snapshots/consumers-no-nest.snap +16 -15
- data/spec/snapshots/consumers.snap +16 -15
- data/spec/snapshots/consumers_and_producers-no-nest.snap +18 -17
- data/spec/snapshots/consumers_and_producers.snap +18 -17
- data/spec/snapshots/consumers_circular-no-nest.snap +16 -15
- data/spec/snapshots/consumers_circular.snap +16 -15
- data/spec/snapshots/consumers_complex_types-no-nest.snap +16 -15
- data/spec/snapshots/consumers_complex_types.snap +16 -15
- data/spec/snapshots/consumers_nested-no-nest.snap +16 -15
- data/spec/snapshots/consumers_nested.snap +16 -15
- data/spec/snapshots/namespace_folders.snap +18 -17
- data/spec/snapshots/namespace_map.snap +18 -17
- data/spec/snapshots/producers_with_key-no-nest.snap +18 -17
- data/spec/snapshots/producers_with_key.snap +18 -17
- data/spec/spec_helper.rb +1 -1
- metadata +3 -2
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# This file is autogenerated by Deimos, Do NOT modify
|
4
|
-
module Schemas
|
4
|
+
module Schemas; module MyNamespace
|
5
5
|
### Primary Schema Class ###
|
6
6
|
# Autogenerated Schema for Record at com.my-namespace.MySchemaWithUnionType
|
7
7
|
class MySchemaWithUnionType < Deimos::SchemaClass::Record
|
@@ -9,13 +9,13 @@ module Schemas
|
|
9
9
|
### Secondary Schema Classes ###
|
10
10
|
# Autogenerated Schema for Record at com.flipp.content.Record1
|
11
11
|
class Record1 < Deimos::SchemaClass::Record
|
12
|
-
|
12
|
+
|
13
13
|
### Attribute Accessors ###
|
14
14
|
# @return [Hash<String, Integer>]
|
15
15
|
attr_accessor :record1_map
|
16
16
|
# @return [Integer]
|
17
17
|
attr_accessor :record1_id
|
18
|
-
|
18
|
+
|
19
19
|
# @override
|
20
20
|
def initialize(record1_map: {},
|
21
21
|
record1_id: 0)
|
@@ -23,17 +23,17 @@ module Schemas
|
|
23
23
|
self.record1_map = record1_map
|
24
24
|
self.record1_id = record1_id
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
# @override
|
28
28
|
def schema
|
29
29
|
'Record1'
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
# @override
|
33
33
|
def namespace
|
34
34
|
'com.flipp.content'
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
# @override
|
38
38
|
def as_json(_opts={})
|
39
39
|
{
|
@@ -45,27 +45,27 @@ module Schemas
|
|
45
45
|
|
46
46
|
# Autogenerated Schema for Record at com.flipp.content.Record2
|
47
47
|
class Record2 < Deimos::SchemaClass::Record
|
48
|
-
|
48
|
+
|
49
49
|
### Attribute Accessors ###
|
50
50
|
# @return [String]
|
51
51
|
attr_accessor :record2_id
|
52
|
-
|
52
|
+
|
53
53
|
# @override
|
54
54
|
def initialize(record2_id: "")
|
55
55
|
super
|
56
56
|
self.record2_id = record2_id
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
# @override
|
60
60
|
def schema
|
61
61
|
'Record2'
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
# @override
|
65
65
|
def namespace
|
66
66
|
'com.flipp.content'
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
# @override
|
70
70
|
def as_json(_opts={})
|
71
71
|
{
|
@@ -76,27 +76,27 @@ module Schemas
|
|
76
76
|
|
77
77
|
# Autogenerated Schema for Record at com.flipp.content.Record3
|
78
78
|
class Record3 < Deimos::SchemaClass::Record
|
79
|
-
|
79
|
+
|
80
80
|
### Attribute Accessors ###
|
81
81
|
# @return [Float]
|
82
82
|
attr_accessor :record3_id
|
83
|
-
|
83
|
+
|
84
84
|
# @override
|
85
85
|
def initialize(record3_id: 0.0)
|
86
86
|
super
|
87
87
|
self.record3_id = record3_id
|
88
88
|
end
|
89
|
-
|
89
|
+
|
90
90
|
# @override
|
91
91
|
def schema
|
92
92
|
'Record3'
|
93
93
|
end
|
94
|
-
|
94
|
+
|
95
95
|
# @override
|
96
96
|
def namespace
|
97
97
|
'com.flipp.content'
|
98
98
|
end
|
99
|
-
|
99
|
+
|
100
100
|
# @override
|
101
101
|
def as_json(_opts={})
|
102
102
|
{
|
@@ -107,27 +107,27 @@ module Schemas
|
|
107
107
|
|
108
108
|
# Autogenerated Schema for Record at com.flipp.content.Record4
|
109
109
|
class Record4 < Deimos::SchemaClass::Record
|
110
|
-
|
110
|
+
|
111
111
|
### Attribute Accessors ###
|
112
112
|
# @return [Integer]
|
113
113
|
attr_accessor :record4_id
|
114
|
-
|
114
|
+
|
115
115
|
# @override
|
116
116
|
def initialize(record4_id: 0)
|
117
117
|
super
|
118
118
|
self.record4_id = record4_id
|
119
119
|
end
|
120
|
-
|
120
|
+
|
121
121
|
# @override
|
122
122
|
def schema
|
123
123
|
'Record4'
|
124
124
|
end
|
125
|
-
|
125
|
+
|
126
126
|
# @override
|
127
127
|
def namespace
|
128
128
|
'com.flipp.content'
|
129
129
|
end
|
130
|
-
|
130
|
+
|
131
131
|
# @override
|
132
132
|
def as_json(_opts={})
|
133
133
|
{
|
@@ -150,7 +150,22 @@ module Schemas
|
|
150
150
|
### Attribute Writers ###
|
151
151
|
# @return [nil, Record1, Record2, Record3, Record4, Integer, Array<String>]
|
152
152
|
def test_union_type=(value)
|
153
|
-
@test_union_type =
|
153
|
+
@test_union_type = initialize_test_union_type_type(value, from_message: @from_message)
|
154
|
+
end
|
155
|
+
|
156
|
+
# Helper method to determine which schema type to use for test_union_type
|
157
|
+
# @param value [Hash, nil]
|
158
|
+
# @param from_message [Boolean] whether this was initialized from a real Avro message
|
159
|
+
# @return [Object, nil]
|
160
|
+
def initialize_test_union_type_type(value, from_message: false)
|
161
|
+
return nil if value.nil?
|
162
|
+
|
163
|
+
klass = [Record1, Record2, Record3, Record4].find do |candidate|
|
164
|
+
fields = candidate.new.as_json.keys
|
165
|
+
(value.keys - fields).empty?
|
166
|
+
end
|
167
|
+
|
168
|
+
klass.initialize_from_value(value, from_message: @from_message)
|
154
169
|
end
|
155
170
|
|
156
171
|
# @override
|
@@ -182,4 +197,4 @@ module Schemas
|
|
182
197
|
}
|
183
198
|
end
|
184
199
|
end
|
185
|
-
end
|
200
|
+
end; end
|
@@ -154,12 +154,12 @@ module Schemas
|
|
154
154
|
### Attribute Writers ###
|
155
155
|
# @return [AnEnum]
|
156
156
|
def an_enum=(value)
|
157
|
-
@an_enum = AnEnum.initialize_from_value(value)
|
157
|
+
@an_enum = AnEnum.initialize_from_value(value, from_message: @from_message)
|
158
158
|
end
|
159
159
|
|
160
160
|
# @return [ARecord]
|
161
161
|
def a_record=(value)
|
162
|
-
@a_record = ARecord.initialize_from_value(value)
|
162
|
+
@a_record = ARecord.initialize_from_value(value, from_message: @from_message)
|
163
163
|
end
|
164
164
|
|
165
165
|
# @override
|
@@ -391,12 +391,12 @@ module Schemas
|
|
391
391
|
### Attribute Writers ###
|
392
392
|
# @return [MyNestedRecord]
|
393
393
|
def some_nested_record=(value)
|
394
|
-
@some_nested_record = MyNestedRecord.initialize_from_value(value)
|
394
|
+
@some_nested_record = MyNestedRecord.initialize_from_value(value, from_message: @from_message)
|
395
395
|
end
|
396
396
|
|
397
397
|
# @return [nil, MyNestedRecord]
|
398
398
|
def some_optional_record=(value)
|
399
|
-
@some_optional_record = MyNestedRecord.initialize_from_value(value)
|
399
|
+
@some_optional_record = MyNestedRecord.initialize_from_value(value, from_message: @from_message)
|
400
400
|
end
|
401
401
|
|
402
402
|
# @override
|
@@ -664,7 +664,7 @@ module Schemas
|
|
664
664
|
# @return [Hash<String, Property>]
|
665
665
|
def properties=(values)
|
666
666
|
@properties = values&.transform_values do |value|
|
667
|
-
Property.initialize_from_value(value)
|
667
|
+
Property.initialize_from_value(value, from_message: @from_message)
|
668
668
|
end
|
669
669
|
end
|
670
670
|
|
@@ -736,43 +736,43 @@ module Schemas
|
|
736
736
|
### Attribute Writers ###
|
737
737
|
# @return [ARecord]
|
738
738
|
def some_record=(value)
|
739
|
-
@some_record = ARecord.initialize_from_value(value)
|
739
|
+
@some_record = ARecord.initialize_from_value(value, from_message: @from_message)
|
740
740
|
end
|
741
741
|
|
742
742
|
# @return [nil, ARecord]
|
743
743
|
def some_optional_record=(value)
|
744
|
-
@some_optional_record = ARecord.initialize_from_value(value)
|
744
|
+
@some_optional_record = ARecord.initialize_from_value(value, from_message: @from_message)
|
745
745
|
end
|
746
746
|
|
747
747
|
# @return [Array<ARecord>]
|
748
748
|
def some_record_array=(values)
|
749
749
|
@some_record_array = values&.map do |value|
|
750
|
-
ARecord.initialize_from_value(value)
|
750
|
+
ARecord.initialize_from_value(value, from_message: @from_message)
|
751
751
|
end
|
752
752
|
end
|
753
753
|
|
754
754
|
# @return [Hash<String, ARecord>]
|
755
755
|
def some_record_map=(values)
|
756
756
|
@some_record_map = values&.transform_values do |value|
|
757
|
-
ARecord.initialize_from_value(value)
|
757
|
+
ARecord.initialize_from_value(value, from_message: @from_message)
|
758
758
|
end
|
759
759
|
end
|
760
760
|
|
761
761
|
# @return [Array<AnEnum>]
|
762
762
|
def some_enum_array=(values)
|
763
763
|
@some_enum_array = values&.map do |value|
|
764
|
-
AnEnum.initialize_from_value(value)
|
764
|
+
AnEnum.initialize_from_value(value, from_message: @from_message)
|
765
765
|
end
|
766
766
|
end
|
767
767
|
|
768
768
|
# @return [nil, AnotherEnum]
|
769
769
|
def some_optional_enum=(value)
|
770
|
-
@some_optional_enum = AnotherEnum.initialize_from_value(value)
|
770
|
+
@some_optional_enum = AnotherEnum.initialize_from_value(value, from_message: @from_message)
|
771
771
|
end
|
772
772
|
|
773
773
|
# @return [YetAnotherEnum]
|
774
774
|
def some_enum_with_default=(value)
|
775
|
-
@some_enum_with_default = YetAnotherEnum.initialize_from_value(value)
|
775
|
+
@some_enum_with_default = YetAnotherEnum.initialize_from_value(value, from_message: @from_message)
|
776
776
|
end
|
777
777
|
|
778
778
|
# @override
|
@@ -1021,13 +1021,14 @@ module Schemas
|
|
1021
1021
|
### Attribute Writers ###
|
1022
1022
|
# @return [nil, Record1, Record2, Record3, Record4, Integer, Array<String>]
|
1023
1023
|
def test_union_type=(value)
|
1024
|
-
@test_union_type = initialize_test_union_type_type(value)
|
1024
|
+
@test_union_type = initialize_test_union_type_type(value, from_message: @from_message)
|
1025
1025
|
end
|
1026
1026
|
|
1027
1027
|
# Helper method to determine which schema type to use for test_union_type
|
1028
1028
|
# @param value [Hash, nil]
|
1029
|
+
# @param from_message [Boolean] whether this was initialized from a real Avro message
|
1029
1030
|
# @return [Object, nil]
|
1030
|
-
def initialize_test_union_type_type(value)
|
1031
|
+
def initialize_test_union_type_type(value, from_message: false)
|
1031
1032
|
return nil if value.nil?
|
1032
1033
|
|
1033
1034
|
klass = [Record1, Record2, Record3, Record4].find do |candidate|
|
@@ -1035,7 +1036,7 @@ module Schemas
|
|
1035
1036
|
(value.keys - fields).empty?
|
1036
1037
|
end
|
1037
1038
|
|
1038
|
-
klass.initialize_from_value(value)
|
1039
|
+
klass.initialize_from_value(value, from_message: @from_message)
|
1039
1040
|
end
|
1040
1041
|
|
1041
1042
|
# @override
|
@@ -121,12 +121,12 @@ module Schemas
|
|
121
121
|
### Attribute Writers ###
|
122
122
|
# @return [AnEnum]
|
123
123
|
def an_enum=(value)
|
124
|
-
@an_enum = AnEnum.initialize_from_value(value)
|
124
|
+
@an_enum = AnEnum.initialize_from_value(value, from_message: @from_message)
|
125
125
|
end
|
126
126
|
|
127
127
|
# @return [ARecord]
|
128
128
|
def a_record=(value)
|
129
|
-
@a_record = ARecord.initialize_from_value(value)
|
129
|
+
@a_record = ARecord.initialize_from_value(value, from_message: @from_message)
|
130
130
|
end
|
131
131
|
|
132
132
|
# @override
|
@@ -352,12 +352,12 @@ module Schemas
|
|
352
352
|
### Attribute Writers ###
|
353
353
|
# @return [MyNestedRecord]
|
354
354
|
def some_nested_record=(value)
|
355
|
-
@some_nested_record = MyNestedRecord.initialize_from_value(value)
|
355
|
+
@some_nested_record = MyNestedRecord.initialize_from_value(value, from_message: @from_message)
|
356
356
|
end
|
357
357
|
|
358
358
|
# @return [nil, MyNestedRecord]
|
359
359
|
def some_optional_record=(value)
|
360
|
-
@some_optional_record = MyNestedRecord.initialize_from_value(value)
|
360
|
+
@some_optional_record = MyNestedRecord.initialize_from_value(value, from_message: @from_message)
|
361
361
|
end
|
362
362
|
|
363
363
|
# @override
|
@@ -658,7 +658,7 @@ module Schemas
|
|
658
658
|
# @return [Hash<String, Property>]
|
659
659
|
def properties=(values)
|
660
660
|
@properties = values&.transform_values do |value|
|
661
|
-
Property.initialize_from_value(value)
|
661
|
+
Property.initialize_from_value(value, from_message: @from_message)
|
662
662
|
end
|
663
663
|
end
|
664
664
|
|
@@ -796,43 +796,43 @@ module Schemas
|
|
796
796
|
### Attribute Writers ###
|
797
797
|
# @return [ARecord]
|
798
798
|
def some_record=(value)
|
799
|
-
@some_record = ARecord.initialize_from_value(value)
|
799
|
+
@some_record = ARecord.initialize_from_value(value, from_message: @from_message)
|
800
800
|
end
|
801
801
|
|
802
802
|
# @return [nil, ARecord]
|
803
803
|
def some_optional_record=(value)
|
804
|
-
@some_optional_record = ARecord.initialize_from_value(value)
|
804
|
+
@some_optional_record = ARecord.initialize_from_value(value, from_message: @from_message)
|
805
805
|
end
|
806
806
|
|
807
807
|
# @return [Array<ARecord>]
|
808
808
|
def some_record_array=(values)
|
809
809
|
@some_record_array = values&.map do |value|
|
810
|
-
ARecord.initialize_from_value(value)
|
810
|
+
ARecord.initialize_from_value(value, from_message: @from_message)
|
811
811
|
end
|
812
812
|
end
|
813
813
|
|
814
814
|
# @return [Hash<String, ARecord>]
|
815
815
|
def some_record_map=(values)
|
816
816
|
@some_record_map = values&.transform_values do |value|
|
817
|
-
ARecord.initialize_from_value(value)
|
817
|
+
ARecord.initialize_from_value(value, from_message: @from_message)
|
818
818
|
end
|
819
819
|
end
|
820
820
|
|
821
821
|
# @return [Array<AnEnum>]
|
822
822
|
def some_enum_array=(values)
|
823
823
|
@some_enum_array = values&.map do |value|
|
824
|
-
AnEnum.initialize_from_value(value)
|
824
|
+
AnEnum.initialize_from_value(value, from_message: @from_message)
|
825
825
|
end
|
826
826
|
end
|
827
827
|
|
828
828
|
# @return [nil, AnotherEnum]
|
829
829
|
def some_optional_enum=(value)
|
830
|
-
@some_optional_enum = AnotherEnum.initialize_from_value(value)
|
830
|
+
@some_optional_enum = AnotherEnum.initialize_from_value(value, from_message: @from_message)
|
831
831
|
end
|
832
832
|
|
833
833
|
# @return [YetAnotherEnum]
|
834
834
|
def some_enum_with_default=(value)
|
835
|
-
@some_enum_with_default = YetAnotherEnum.initialize_from_value(value)
|
835
|
+
@some_enum_with_default = YetAnotherEnum.initialize_from_value(value, from_message: @from_message)
|
836
836
|
end
|
837
837
|
|
838
838
|
# @override
|
@@ -1212,13 +1212,14 @@ module Schemas
|
|
1212
1212
|
### Attribute Writers ###
|
1213
1213
|
# @return [nil, Record1, Record2, Record3, Record4, Integer, Array<String>]
|
1214
1214
|
def test_union_type=(value)
|
1215
|
-
@test_union_type = initialize_test_union_type_type(value)
|
1215
|
+
@test_union_type = initialize_test_union_type_type(value, from_message: @from_message)
|
1216
1216
|
end
|
1217
1217
|
|
1218
1218
|
# Helper method to determine which schema type to use for test_union_type
|
1219
1219
|
# @param value [Hash, nil]
|
1220
|
+
# @param from_message [Boolean] whether this was initialized from a real Avro message
|
1220
1221
|
# @return [Object, nil]
|
1221
|
-
def initialize_test_union_type_type(value)
|
1222
|
+
def initialize_test_union_type_type(value, from_message: false)
|
1222
1223
|
return nil if value.nil?
|
1223
1224
|
|
1224
1225
|
klass = [Record1, Record2, Record3, Record4].find do |candidate|
|
@@ -1226,7 +1227,7 @@ module Schemas
|
|
1226
1227
|
(value.keys - fields).empty?
|
1227
1228
|
end
|
1228
1229
|
|
1229
|
-
klass.initialize_from_value(value)
|
1230
|
+
klass.initialize_from_value(value, from_message: @from_message)
|
1230
1231
|
end
|
1231
1232
|
|
1232
1233
|
# @override
|
@@ -154,12 +154,12 @@ module Schemas
|
|
154
154
|
### Attribute Writers ###
|
155
155
|
# @return [AnEnum]
|
156
156
|
def an_enum=(value)
|
157
|
-
@an_enum = AnEnum.initialize_from_value(value)
|
157
|
+
@an_enum = AnEnum.initialize_from_value(value, from_message: @from_message)
|
158
158
|
end
|
159
159
|
|
160
160
|
# @return [ARecord]
|
161
161
|
def a_record=(value)
|
162
|
-
@a_record = ARecord.initialize_from_value(value)
|
162
|
+
@a_record = ARecord.initialize_from_value(value, from_message: @from_message)
|
163
163
|
end
|
164
164
|
|
165
165
|
# @override
|
@@ -391,12 +391,12 @@ module Schemas
|
|
391
391
|
### Attribute Writers ###
|
392
392
|
# @return [MyNestedRecord]
|
393
393
|
def some_nested_record=(value)
|
394
|
-
@some_nested_record = MyNestedRecord.initialize_from_value(value)
|
394
|
+
@some_nested_record = MyNestedRecord.initialize_from_value(value, from_message: @from_message)
|
395
395
|
end
|
396
396
|
|
397
397
|
# @return [nil, MyNestedRecord]
|
398
398
|
def some_optional_record=(value)
|
399
|
-
@some_optional_record = MyNestedRecord.initialize_from_value(value)
|
399
|
+
@some_optional_record = MyNestedRecord.initialize_from_value(value, from_message: @from_message)
|
400
400
|
end
|
401
401
|
|
402
402
|
# @override
|
@@ -466,7 +466,7 @@ module Schemas
|
|
466
466
|
### Attribute Writers ###
|
467
467
|
# @return [MySchemaKey]
|
468
468
|
def payload_key=(value)
|
469
|
-
@payload_key = MySchemaKey.initialize_from_value(value)
|
469
|
+
@payload_key = MySchemaKey.initialize_from_value(value, from_message: @from_message)
|
470
470
|
end
|
471
471
|
|
472
472
|
# @override
|
@@ -491,7 +491,7 @@ module Schemas
|
|
491
491
|
|
492
492
|
def self.tombstone(key)
|
493
493
|
record = self.allocate
|
494
|
-
record.tombstone_key = MySchemaKey.initialize_from_value(key)
|
494
|
+
record.tombstone_key = MySchemaKey.initialize_from_value(key, from_message: @from_message)
|
495
495
|
record.payload_key = key
|
496
496
|
record
|
497
497
|
end
|
@@ -691,7 +691,7 @@ module Schemas
|
|
691
691
|
# @return [Hash<String, Property>]
|
692
692
|
def properties=(values)
|
693
693
|
@properties = values&.transform_values do |value|
|
694
|
-
Property.initialize_from_value(value)
|
694
|
+
Property.initialize_from_value(value, from_message: @from_message)
|
695
695
|
end
|
696
696
|
end
|
697
697
|
|
@@ -763,43 +763,43 @@ module Schemas
|
|
763
763
|
### Attribute Writers ###
|
764
764
|
# @return [ARecord]
|
765
765
|
def some_record=(value)
|
766
|
-
@some_record = ARecord.initialize_from_value(value)
|
766
|
+
@some_record = ARecord.initialize_from_value(value, from_message: @from_message)
|
767
767
|
end
|
768
768
|
|
769
769
|
# @return [nil, ARecord]
|
770
770
|
def some_optional_record=(value)
|
771
|
-
@some_optional_record = ARecord.initialize_from_value(value)
|
771
|
+
@some_optional_record = ARecord.initialize_from_value(value, from_message: @from_message)
|
772
772
|
end
|
773
773
|
|
774
774
|
# @return [Array<ARecord>]
|
775
775
|
def some_record_array=(values)
|
776
776
|
@some_record_array = values&.map do |value|
|
777
|
-
ARecord.initialize_from_value(value)
|
777
|
+
ARecord.initialize_from_value(value, from_message: @from_message)
|
778
778
|
end
|
779
779
|
end
|
780
780
|
|
781
781
|
# @return [Hash<String, ARecord>]
|
782
782
|
def some_record_map=(values)
|
783
783
|
@some_record_map = values&.transform_values do |value|
|
784
|
-
ARecord.initialize_from_value(value)
|
784
|
+
ARecord.initialize_from_value(value, from_message: @from_message)
|
785
785
|
end
|
786
786
|
end
|
787
787
|
|
788
788
|
# @return [Array<AnEnum>]
|
789
789
|
def some_enum_array=(values)
|
790
790
|
@some_enum_array = values&.map do |value|
|
791
|
-
AnEnum.initialize_from_value(value)
|
791
|
+
AnEnum.initialize_from_value(value, from_message: @from_message)
|
792
792
|
end
|
793
793
|
end
|
794
794
|
|
795
795
|
# @return [nil, AnotherEnum]
|
796
796
|
def some_optional_enum=(value)
|
797
|
-
@some_optional_enum = AnotherEnum.initialize_from_value(value)
|
797
|
+
@some_optional_enum = AnotherEnum.initialize_from_value(value, from_message: @from_message)
|
798
798
|
end
|
799
799
|
|
800
800
|
# @return [YetAnotherEnum]
|
801
801
|
def some_enum_with_default=(value)
|
802
|
-
@some_enum_with_default = YetAnotherEnum.initialize_from_value(value)
|
802
|
+
@some_enum_with_default = YetAnotherEnum.initialize_from_value(value, from_message: @from_message)
|
803
803
|
end
|
804
804
|
|
805
805
|
# @override
|
@@ -1048,13 +1048,14 @@ module Schemas
|
|
1048
1048
|
### Attribute Writers ###
|
1049
1049
|
# @return [nil, Record1, Record2, Record3, Record4, Integer, Array<String>]
|
1050
1050
|
def test_union_type=(value)
|
1051
|
-
@test_union_type = initialize_test_union_type_type(value)
|
1051
|
+
@test_union_type = initialize_test_union_type_type(value, from_message: @from_message)
|
1052
1052
|
end
|
1053
1053
|
|
1054
1054
|
# Helper method to determine which schema type to use for test_union_type
|
1055
1055
|
# @param value [Hash, nil]
|
1056
|
+
# @param from_message [Boolean] whether this was initialized from a real Avro message
|
1056
1057
|
# @return [Object, nil]
|
1057
|
-
def initialize_test_union_type_type(value)
|
1058
|
+
def initialize_test_union_type_type(value, from_message: false)
|
1058
1059
|
return nil if value.nil?
|
1059
1060
|
|
1060
1061
|
klass = [Record1, Record2, Record3, Record4].find do |candidate|
|
@@ -1062,7 +1063,7 @@ module Schemas
|
|
1062
1063
|
(value.keys - fields).empty?
|
1063
1064
|
end
|
1064
1065
|
|
1065
|
-
klass.initialize_from_value(value)
|
1066
|
+
klass.initialize_from_value(value, from_message: @from_message)
|
1066
1067
|
end
|
1067
1068
|
|
1068
1069
|
# @override
|
@@ -121,12 +121,12 @@ module Schemas
|
|
121
121
|
### Attribute Writers ###
|
122
122
|
# @return [AnEnum]
|
123
123
|
def an_enum=(value)
|
124
|
-
@an_enum = AnEnum.initialize_from_value(value)
|
124
|
+
@an_enum = AnEnum.initialize_from_value(value, from_message: @from_message)
|
125
125
|
end
|
126
126
|
|
127
127
|
# @return [ARecord]
|
128
128
|
def a_record=(value)
|
129
|
-
@a_record = ARecord.initialize_from_value(value)
|
129
|
+
@a_record = ARecord.initialize_from_value(value, from_message: @from_message)
|
130
130
|
end
|
131
131
|
|
132
132
|
# @override
|
@@ -352,12 +352,12 @@ module Schemas
|
|
352
352
|
### Attribute Writers ###
|
353
353
|
# @return [MyNestedRecord]
|
354
354
|
def some_nested_record=(value)
|
355
|
-
@some_nested_record = MyNestedRecord.initialize_from_value(value)
|
355
|
+
@some_nested_record = MyNestedRecord.initialize_from_value(value, from_message: @from_message)
|
356
356
|
end
|
357
357
|
|
358
358
|
# @return [nil, MyNestedRecord]
|
359
359
|
def some_optional_record=(value)
|
360
|
-
@some_optional_record = MyNestedRecord.initialize_from_value(value)
|
360
|
+
@some_optional_record = MyNestedRecord.initialize_from_value(value, from_message: @from_message)
|
361
361
|
end
|
362
362
|
|
363
363
|
# @override
|
@@ -427,7 +427,7 @@ module Schemas
|
|
427
427
|
### Attribute Writers ###
|
428
428
|
# @return [MySchemaKey]
|
429
429
|
def payload_key=(value)
|
430
|
-
@payload_key = MySchemaKey.initialize_from_value(value)
|
430
|
+
@payload_key = MySchemaKey.initialize_from_value(value, from_message: @from_message)
|
431
431
|
end
|
432
432
|
|
433
433
|
# @override
|
@@ -452,7 +452,7 @@ module Schemas
|
|
452
452
|
|
453
453
|
def self.tombstone(key)
|
454
454
|
record = self.allocate
|
455
|
-
record.tombstone_key = MySchemaKey.initialize_from_value(key)
|
455
|
+
record.tombstone_key = MySchemaKey.initialize_from_value(key, from_message: @from_message)
|
456
456
|
record.payload_key = key
|
457
457
|
record
|
458
458
|
end
|
@@ -685,7 +685,7 @@ module Schemas
|
|
685
685
|
# @return [Hash<String, Property>]
|
686
686
|
def properties=(values)
|
687
687
|
@properties = values&.transform_values do |value|
|
688
|
-
Property.initialize_from_value(value)
|
688
|
+
Property.initialize_from_value(value, from_message: @from_message)
|
689
689
|
end
|
690
690
|
end
|
691
691
|
|
@@ -823,43 +823,43 @@ module Schemas
|
|
823
823
|
### Attribute Writers ###
|
824
824
|
# @return [ARecord]
|
825
825
|
def some_record=(value)
|
826
|
-
@some_record = ARecord.initialize_from_value(value)
|
826
|
+
@some_record = ARecord.initialize_from_value(value, from_message: @from_message)
|
827
827
|
end
|
828
828
|
|
829
829
|
# @return [nil, ARecord]
|
830
830
|
def some_optional_record=(value)
|
831
|
-
@some_optional_record = ARecord.initialize_from_value(value)
|
831
|
+
@some_optional_record = ARecord.initialize_from_value(value, from_message: @from_message)
|
832
832
|
end
|
833
833
|
|
834
834
|
# @return [Array<ARecord>]
|
835
835
|
def some_record_array=(values)
|
836
836
|
@some_record_array = values&.map do |value|
|
837
|
-
ARecord.initialize_from_value(value)
|
837
|
+
ARecord.initialize_from_value(value, from_message: @from_message)
|
838
838
|
end
|
839
839
|
end
|
840
840
|
|
841
841
|
# @return [Hash<String, ARecord>]
|
842
842
|
def some_record_map=(values)
|
843
843
|
@some_record_map = values&.transform_values do |value|
|
844
|
-
ARecord.initialize_from_value(value)
|
844
|
+
ARecord.initialize_from_value(value, from_message: @from_message)
|
845
845
|
end
|
846
846
|
end
|
847
847
|
|
848
848
|
# @return [Array<AnEnum>]
|
849
849
|
def some_enum_array=(values)
|
850
850
|
@some_enum_array = values&.map do |value|
|
851
|
-
AnEnum.initialize_from_value(value)
|
851
|
+
AnEnum.initialize_from_value(value, from_message: @from_message)
|
852
852
|
end
|
853
853
|
end
|
854
854
|
|
855
855
|
# @return [nil, AnotherEnum]
|
856
856
|
def some_optional_enum=(value)
|
857
|
-
@some_optional_enum = AnotherEnum.initialize_from_value(value)
|
857
|
+
@some_optional_enum = AnotherEnum.initialize_from_value(value, from_message: @from_message)
|
858
858
|
end
|
859
859
|
|
860
860
|
# @return [YetAnotherEnum]
|
861
861
|
def some_enum_with_default=(value)
|
862
|
-
@some_enum_with_default = YetAnotherEnum.initialize_from_value(value)
|
862
|
+
@some_enum_with_default = YetAnotherEnum.initialize_from_value(value, from_message: @from_message)
|
863
863
|
end
|
864
864
|
|
865
865
|
# @override
|
@@ -1239,13 +1239,14 @@ module Schemas
|
|
1239
1239
|
### Attribute Writers ###
|
1240
1240
|
# @return [nil, Record1, Record2, Record3, Record4, Integer, Array<String>]
|
1241
1241
|
def test_union_type=(value)
|
1242
|
-
@test_union_type = initialize_test_union_type_type(value)
|
1242
|
+
@test_union_type = initialize_test_union_type_type(value, from_message: @from_message)
|
1243
1243
|
end
|
1244
1244
|
|
1245
1245
|
# Helper method to determine which schema type to use for test_union_type
|
1246
1246
|
# @param value [Hash, nil]
|
1247
|
+
# @param from_message [Boolean] whether this was initialized from a real Avro message
|
1247
1248
|
# @return [Object, nil]
|
1248
|
-
def initialize_test_union_type_type(value)
|
1249
|
+
def initialize_test_union_type_type(value, from_message: false)
|
1249
1250
|
return nil if value.nil?
|
1250
1251
|
|
1251
1252
|
klass = [Record1, Record2, Record3, Record4].find do |candidate|
|
@@ -1253,7 +1254,7 @@ module Schemas
|
|
1253
1254
|
(value.keys - fields).empty?
|
1254
1255
|
end
|
1255
1256
|
|
1256
|
-
klass.initialize_from_value(value)
|
1257
|
+
klass.initialize_from_value(value, from_message: @from_message)
|
1257
1258
|
end
|
1258
1259
|
|
1259
1260
|
# @override
|