deimos-ruby 2.0.17 → 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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/README.md +2 -0
  4. data/karafka.rb +1 -0
  5. data/lib/deimos/schema_class/enum.rb +1 -1
  6. data/lib/deimos/schema_class/record.rb +19 -2
  7. data/lib/deimos/test_helpers.rb +18 -6
  8. data/lib/deimos/utils/schema_class.rb +1 -1
  9. data/lib/deimos/version.rb +1 -1
  10. data/lib/generators/deimos/schema_class/templates/schema_record.rb.tt +3 -2
  11. data/lib/generators/deimos/schema_class_generator.rb +3 -3
  12. data/spec/batch_consumer_spec.rb +14 -12
  13. data/spec/consumer_spec.rb +51 -5
  14. data/spec/schemas/my_namespace/generated.rb +2 -2
  15. data/spec/schemas/my_namespace/my_nested_schema.rb +2 -2
  16. data/spec/schemas/my_namespace/my_schema.rb +2 -2
  17. data/spec/schemas/my_namespace/my_schema_with_circular_reference.rb +1 -1
  18. data/spec/schemas/my_namespace/my_schema_with_complex_type.rb +9 -9
  19. data/spec/schemas/my_namespace/my_schema_with_union_type.rb +38 -23
  20. data/spec/snapshots/consumers-no-nest.snap +16 -15
  21. data/spec/snapshots/consumers.snap +16 -15
  22. data/spec/snapshots/consumers_and_producers-no-nest.snap +18 -17
  23. data/spec/snapshots/consumers_and_producers.snap +18 -17
  24. data/spec/snapshots/consumers_circular-no-nest.snap +16 -15
  25. data/spec/snapshots/consumers_circular.snap +16 -15
  26. data/spec/snapshots/consumers_complex_types-no-nest.snap +16 -15
  27. data/spec/snapshots/consumers_complex_types.snap +16 -15
  28. data/spec/snapshots/consumers_nested-no-nest.snap +16 -15
  29. data/spec/snapshots/consumers_nested.snap +16 -15
  30. data/spec/snapshots/namespace_folders.snap +18 -17
  31. data/spec/snapshots/namespace_map.snap +18 -17
  32. data/spec/snapshots/producers_with_key-no-nest.snap +18 -17
  33. data/spec/snapshots/producers_with_key.snap +18 -17
  34. data/spec/spec_helper.rb +1 -1
  35. metadata +3 -2
@@ -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
@@ -384,12 +384,12 @@ module Schemas
384
384
  ### Attribute Writers ###
385
385
  # @return [MyNestedRecord]
386
386
  def some_nested_record=(value)
387
- @some_nested_record = MyNestedRecord.initialize_from_value(value)
387
+ @some_nested_record = MyNestedRecord.initialize_from_value(value, from_message: @from_message)
388
388
  end
389
389
 
390
390
  # @return [nil, MyNestedRecord]
391
391
  def some_optional_record=(value)
392
- @some_optional_record = MyNestedRecord.initialize_from_value(value)
392
+ @some_optional_record = MyNestedRecord.initialize_from_value(value, from_message: @from_message)
393
393
  end
394
394
 
395
395
  # @override
@@ -657,7 +657,7 @@ module Schemas
657
657
  # @return [Hash<String, Property>]
658
658
  def properties=(values)
659
659
  @properties = values&.transform_values do |value|
660
- Property.initialize_from_value(value)
660
+ Property.initialize_from_value(value, from_message: @from_message)
661
661
  end
662
662
  end
663
663
 
@@ -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
@@ -345,12 +345,12 @@ module Schemas
345
345
  ### Attribute Writers ###
346
346
  # @return [MyNestedRecord]
347
347
  def some_nested_record=(value)
348
- @some_nested_record = MyNestedRecord.initialize_from_value(value)
348
+ @some_nested_record = MyNestedRecord.initialize_from_value(value, from_message: @from_message)
349
349
  end
350
350
 
351
351
  # @return [nil, MyNestedRecord]
352
352
  def some_optional_record=(value)
353
- @some_optional_record = MyNestedRecord.initialize_from_value(value)
353
+ @some_optional_record = MyNestedRecord.initialize_from_value(value, from_message: @from_message)
354
354
  end
355
355
 
356
356
  # @override
@@ -651,7 +651,7 @@ module Schemas
651
651
  # @return [Hash<String, Property>]
652
652
  def properties=(values)
653
653
  @properties = values&.transform_values do |value|
654
- Property.initialize_from_value(value)
654
+ Property.initialize_from_value(value, from_message: @from_message)
655
655
  end
656
656
  end
657
657
 
@@ -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
@@ -384,12 +384,12 @@ module Schemas
384
384
  ### Attribute Writers ###
385
385
  # @return [MyNestedRecord]
386
386
  def some_nested_record=(value)
387
- @some_nested_record = MyNestedRecord.initialize_from_value(value)
387
+ @some_nested_record = MyNestedRecord.initialize_from_value(value, from_message: @from_message)
388
388
  end
389
389
 
390
390
  # @return [nil, MyNestedRecord]
391
391
  def some_optional_record=(value)
392
- @some_optional_record = MyNestedRecord.initialize_from_value(value)
392
+ @some_optional_record = MyNestedRecord.initialize_from_value(value, from_message: @from_message)
393
393
  end
394
394
 
395
395
  # @override
@@ -657,7 +657,7 @@ module Schemas
657
657
  # @return [Hash<String, Property>]
658
658
  def properties=(values)
659
659
  @properties = values&.transform_values do |value|
660
- Property.initialize_from_value(value)
660
+ Property.initialize_from_value(value, from_message: @from_message)
661
661
  end
662
662
  end
663
663
 
@@ -729,43 +729,43 @@ module Schemas
729
729
  ### Attribute Writers ###
730
730
  # @return [ARecord]
731
731
  def some_record=(value)
732
- @some_record = ARecord.initialize_from_value(value)
732
+ @some_record = ARecord.initialize_from_value(value, from_message: @from_message)
733
733
  end
734
734
 
735
735
  # @return [nil, ARecord]
736
736
  def some_optional_record=(value)
737
- @some_optional_record = ARecord.initialize_from_value(value)
737
+ @some_optional_record = ARecord.initialize_from_value(value, from_message: @from_message)
738
738
  end
739
739
 
740
740
  # @return [Array<ARecord>]
741
741
  def some_record_array=(values)
742
742
  @some_record_array = values&.map do |value|
743
- ARecord.initialize_from_value(value)
743
+ ARecord.initialize_from_value(value, from_message: @from_message)
744
744
  end
745
745
  end
746
746
 
747
747
  # @return [Hash<String, ARecord>]
748
748
  def some_record_map=(values)
749
749
  @some_record_map = values&.transform_values 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 [Array<AnEnum>]
755
755
  def some_enum_array=(values)
756
756
  @some_enum_array = values&.map do |value|
757
- AnEnum.initialize_from_value(value)
757
+ AnEnum.initialize_from_value(value, from_message: @from_message)
758
758
  end
759
759
  end
760
760
 
761
761
  # @return [nil, AnotherEnum]
762
762
  def some_optional_enum=(value)
763
- @some_optional_enum = AnotherEnum.initialize_from_value(value)
763
+ @some_optional_enum = AnotherEnum.initialize_from_value(value, from_message: @from_message)
764
764
  end
765
765
 
766
766
  # @return [YetAnotherEnum]
767
767
  def some_enum_with_default=(value)
768
- @some_enum_with_default = YetAnotherEnum.initialize_from_value(value)
768
+ @some_enum_with_default = YetAnotherEnum.initialize_from_value(value, from_message: @from_message)
769
769
  end
770
770
 
771
771
  # @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
@@ -345,12 +345,12 @@ module Schemas
345
345
  ### Attribute Writers ###
346
346
  # @return [MyNestedRecord]
347
347
  def some_nested_record=(value)
348
- @some_nested_record = MyNestedRecord.initialize_from_value(value)
348
+ @some_nested_record = MyNestedRecord.initialize_from_value(value, from_message: @from_message)
349
349
  end
350
350
 
351
351
  # @return [nil, MyNestedRecord]
352
352
  def some_optional_record=(value)
353
- @some_optional_record = MyNestedRecord.initialize_from_value(value)
353
+ @some_optional_record = MyNestedRecord.initialize_from_value(value, from_message: @from_message)
354
354
  end
355
355
 
356
356
  # @override
@@ -651,7 +651,7 @@ module Schemas
651
651
  # @return [Hash<String, Property>]
652
652
  def properties=(values)
653
653
  @properties = values&.transform_values do |value|
654
- Property.initialize_from_value(value)
654
+ Property.initialize_from_value(value, from_message: @from_message)
655
655
  end
656
656
  end
657
657
 
@@ -789,43 +789,43 @@ module Schemas
789
789
  ### Attribute Writers ###
790
790
  # @return [ARecord]
791
791
  def some_record=(value)
792
- @some_record = ARecord.initialize_from_value(value)
792
+ @some_record = ARecord.initialize_from_value(value, from_message: @from_message)
793
793
  end
794
794
 
795
795
  # @return [nil, ARecord]
796
796
  def some_optional_record=(value)
797
- @some_optional_record = ARecord.initialize_from_value(value)
797
+ @some_optional_record = ARecord.initialize_from_value(value, from_message: @from_message)
798
798
  end
799
799
 
800
800
  # @return [Array<ARecord>]
801
801
  def some_record_array=(values)
802
802
  @some_record_array = values&.map do |value|
803
- ARecord.initialize_from_value(value)
803
+ ARecord.initialize_from_value(value, from_message: @from_message)
804
804
  end
805
805
  end
806
806
 
807
807
  # @return [Hash<String, ARecord>]
808
808
  def some_record_map=(values)
809
809
  @some_record_map = values&.transform_values 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 [Array<AnEnum>]
815
815
  def some_enum_array=(values)
816
816
  @some_enum_array = values&.map do |value|
817
- AnEnum.initialize_from_value(value)
817
+ AnEnum.initialize_from_value(value, from_message: @from_message)
818
818
  end
819
819
  end
820
820
 
821
821
  # @return [nil, AnotherEnum]
822
822
  def some_optional_enum=(value)
823
- @some_optional_enum = AnotherEnum.initialize_from_value(value)
823
+ @some_optional_enum = AnotherEnum.initialize_from_value(value, from_message: @from_message)
824
824
  end
825
825
 
826
826
  # @return [YetAnotherEnum]
827
827
  def some_enum_with_default=(value)
828
- @some_enum_with_default = YetAnotherEnum.initialize_from_value(value)
828
+ @some_enum_with_default = YetAnotherEnum.initialize_from_value(value, from_message: @from_message)
829
829
  end
830
830
 
831
831
  # @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
@@ -384,12 +384,12 @@ module Schemas
384
384
  ### Attribute Writers ###
385
385
  # @return [MyNestedRecord]
386
386
  def some_nested_record=(value)
387
- @some_nested_record = MyNestedRecord.initialize_from_value(value)
387
+ @some_nested_record = MyNestedRecord.initialize_from_value(value, from_message: @from_message)
388
388
  end
389
389
 
390
390
  # @return [nil, MyNestedRecord]
391
391
  def some_optional_record=(value)
392
- @some_optional_record = MyNestedRecord.initialize_from_value(value)
392
+ @some_optional_record = MyNestedRecord.initialize_from_value(value, from_message: @from_message)
393
393
  end
394
394
 
395
395
  # @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