deimos-ruby 1.16.0 → 1.16.3

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 (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -1
  3. data/README.md +17 -0
  4. data/lib/deimos/active_record_producer.rb +7 -0
  5. data/lib/deimos/schema_class/base.rb +1 -1
  6. data/lib/deimos/schema_class/enum.rb +5 -0
  7. data/lib/deimos/schema_class/record.rb +7 -1
  8. data/lib/deimos/version.rb +1 -1
  9. data/lib/generators/deimos/schema_class/templates/schema_record.rb.tt +13 -5
  10. data/lib/generators/deimos/schema_class_generator.rb +40 -22
  11. data/regenerate_test_schema_classes.rb +68 -0
  12. data/spec/active_record_producer_spec.rb +24 -0
  13. data/spec/generators/schema_class/my_schema_spec.rb +16 -0
  14. data/spec/generators/schema_class/my_schema_with_circular_reference_spec.rb +1 -1
  15. data/spec/generators/schema_class/my_schema_with_complex_types_spec.rb +32 -24
  16. data/spec/producer_spec.rb +11 -11
  17. data/spec/schemas/{generated.rb → my_namespace/generated.rb} +28 -32
  18. data/spec/schemas/{my_nested_schema.rb → my_namespace/my_nested_schema.rb} +23 -16
  19. data/spec/schemas/{my_schema.rb → my_namespace/my_schema.rb} +12 -5
  20. data/spec/schemas/my_namespace/my_schema_compound_key.rb +41 -0
  21. data/spec/schemas/my_namespace/my_schema_id_key.rb +36 -0
  22. data/spec/schemas/{my_schema_key.rb → my_namespace/my_schema_key.rb} +3 -3
  23. data/spec/schemas/my_namespace/my_schema_with_boolean.rb +41 -0
  24. data/spec/schemas/{my_schema_with_circular_reference.rb → my_namespace/my_schema_with_circular_reference.rb} +15 -10
  25. data/spec/schemas/{my_schema_with_complex_type.rb → my_namespace/my_schema_with_complex_type.rb} +34 -49
  26. data/spec/schemas/my_namespace/my_schema_with_date_time.rb +56 -0
  27. data/spec/schemas/my_namespace/my_schema_with_id.rb +51 -0
  28. data/spec/schemas/my_namespace/my_schema_with_unique_id.rb +56 -0
  29. data/spec/schemas/my_namespace/wibble.rb +76 -0
  30. data/spec/schemas/my_namespace/widget.rb +56 -0
  31. data/spec/schemas/my_namespace/widget_the_second.rb +56 -0
  32. data/spec/schemas/request/create_topic.rb +36 -0
  33. data/spec/schemas/request/index.rb +36 -0
  34. data/spec/schemas/request/update_request.rb +36 -0
  35. data/spec/schemas/response/create_topic.rb +36 -0
  36. data/spec/schemas/response/index.rb +36 -0
  37. data/spec/schemas/response/update_response.rb +36 -0
  38. data/spec/snapshots/consumers-no-nest.snap +93 -86
  39. data/spec/snapshots/consumers.snap +94 -87
  40. data/spec/snapshots/consumers_and_producers-no-nest.snap +108 -87
  41. data/spec/snapshots/consumers_and_producers.snap +109 -88
  42. data/spec/snapshots/consumers_circular-no-nest.snap +93 -86
  43. data/spec/snapshots/consumers_circular.snap +94 -87
  44. data/spec/snapshots/consumers_complex_types-no-nest.snap +93 -86
  45. data/spec/snapshots/consumers_complex_types.snap +94 -87
  46. data/spec/snapshots/consumers_nested-no-nest.snap +93 -86
  47. data/spec/snapshots/consumers_nested.snap +94 -87
  48. data/spec/snapshots/namespace_folders.snap +111 -90
  49. data/spec/snapshots/producers_with_key-no-nest.snap +94 -87
  50. data/spec/snapshots/producers_with_key.snap +95 -88
  51. data/spec/spec_helper.rb +2 -1
  52. metadata +48 -15
@@ -8,7 +8,7 @@ module Schemas
8
8
  class ARecord < Deimos::SchemaClass::Record
9
9
 
10
10
  ### Attribute Accessors ###
11
- # @param value [String]
11
+ # @return [String]
12
12
  attr_accessor :a_record_field
13
13
 
14
14
  # @override
@@ -85,7 +85,7 @@ module Schemas
85
85
  class CreateTopic < Deimos::SchemaClass::Record
86
86
 
87
87
  ### Attribute Accessors ###
88
- # @param value [String]
88
+ # @return [String]
89
89
  attr_accessor :response_id
90
90
 
91
91
  # @override
@@ -130,34 +130,34 @@ module Schemas
130
130
  attr_reader :a_record
131
131
 
132
132
  ### Attribute Accessors ###
133
- # @param value [String]
133
+ # @return [String]
134
134
  attr_accessor :a_string
135
- # @param value [Integer]
135
+ # @return [Integer]
136
136
  attr_accessor :a_int
137
- # @param value [Integer]
137
+ # @return [Integer]
138
138
  attr_accessor :a_long
139
- # @param value [Float]
139
+ # @return [Float]
140
140
  attr_accessor :a_float
141
- # @param value [Float]
141
+ # @return [Float]
142
142
  attr_accessor :a_double
143
- # @param value [nil, Integer]
143
+ # @return [nil, Integer]
144
144
  attr_accessor :an_optional_int
145
- # @param values [Array<Integer>]
145
+ # @return [Array<Integer>]
146
146
  attr_accessor :an_array
147
- # @param values [Hash<String, String>]
147
+ # @return [Hash<String, String>]
148
148
  attr_accessor :a_map
149
- # @param value [String]
149
+ # @return [String]
150
150
  attr_accessor :timestamp
151
- # @param value [String]
151
+ # @return [String]
152
152
  attr_accessor :message_id
153
153
 
154
154
  ### Attribute Writers ###
155
- # @param value [AnEnum]
155
+ # @return [AnEnum]
156
156
  def an_enum=(value)
157
157
  @an_enum = AnEnum.initialize_from_value(value)
158
158
  end
159
159
 
160
- # @param value [ARecord]
160
+ # @return [ARecord]
161
161
  def a_record=(value)
162
162
  @a_record = ARecord.initialize_from_value(value)
163
163
  end
@@ -231,7 +231,7 @@ module Schemas
231
231
  class Index < Deimos::SchemaClass::Record
232
232
 
233
233
  ### Attribute Accessors ###
234
- # @param value [String]
234
+ # @return [String]
235
235
  attr_accessor :response_id
236
236
 
237
237
  # @override
@@ -270,13 +270,13 @@ module Schemas
270
270
  class MyNestedRecord < Deimos::SchemaClass::Record
271
271
 
272
272
  ### Attribute Accessors ###
273
- # @param value [Integer]
273
+ # @return [Integer]
274
274
  attr_accessor :some_int
275
- # @param value [Float]
275
+ # @return [Float]
276
276
  attr_accessor :some_float
277
- # @param value [String]
277
+ # @return [String]
278
278
  attr_accessor :some_string
279
- # @param value [nil, Integer]
279
+ # @return [nil, Integer]
280
280
  attr_accessor :some_optional_int
281
281
 
282
282
  # @override
@@ -330,20 +330,20 @@ module Schemas
330
330
  attr_reader :some_optional_record
331
331
 
332
332
  ### Attribute Accessors ###
333
- # @param value [String]
333
+ # @return [String]
334
334
  attr_accessor :test_id
335
- # @param value [Float]
335
+ # @return [Float]
336
336
  attr_accessor :test_float
337
- # @param values [Array<String>]
337
+ # @return [Array<String>]
338
338
  attr_accessor :test_array
339
339
 
340
340
  ### Attribute Writers ###
341
- # @param value [MyNestedRecord]
341
+ # @return [MyNestedRecord]
342
342
  def some_nested_record=(value)
343
343
  @some_nested_record = MyNestedRecord.initialize_from_value(value)
344
344
  end
345
345
 
346
- # @param value [nil, MyNestedRecord]
346
+ # @return [nil, MyNestedRecord]
347
347
  def some_optional_record=(value)
348
348
  @some_optional_record = MyNestedRecord.initialize_from_value(value)
349
349
  end
@@ -396,9 +396,9 @@ module Schemas
396
396
  class MySchema < Deimos::SchemaClass::Record
397
397
 
398
398
  ### Attribute Accessors ###
399
- # @param value [String]
399
+ # @return [String]
400
400
  attr_accessor :test_id
401
- # @param value [Integer]
401
+ # @return [Integer]
402
402
  attr_accessor :some_int
403
403
 
404
404
  # @override
@@ -440,9 +440,9 @@ module Schemas
440
440
  class MySchemaCompoundKey < Deimos::SchemaClass::Record
441
441
 
442
442
  ### Attribute Accessors ###
443
- # @param value [String]
443
+ # @return [String]
444
444
  attr_accessor :part_one
445
- # @param value [String]
445
+ # @return [String]
446
446
  attr_accessor :part_two
447
447
 
448
448
  # @override
@@ -484,7 +484,7 @@ module Schemas
484
484
  class MySchemaIdKey < Deimos::SchemaClass::Record
485
485
 
486
486
  ### Attribute Accessors ###
487
- # @param value [Integer]
487
+ # @return [Integer]
488
488
  attr_accessor :id
489
489
 
490
490
  # @override
@@ -523,7 +523,7 @@ module Schemas
523
523
  class MySchemaKey < Deimos::SchemaClass::Record
524
524
 
525
525
  ### Attribute Accessors ###
526
- # @param value [String]
526
+ # @return [String]
527
527
  attr_accessor :test_id
528
528
 
529
529
  # @override
@@ -562,9 +562,9 @@ module Schemas
562
562
  class MySchemaWithBoolean < Deimos::SchemaClass::Record
563
563
 
564
564
  ### Attribute Accessors ###
565
- # @param value [String]
565
+ # @return [String]
566
566
  attr_accessor :test_id
567
- # @param value [Boolean]
567
+ # @return [Boolean]
568
568
  attr_accessor :some_bool
569
569
 
570
570
  # @override
@@ -610,9 +610,9 @@ module Schemas
610
610
  attr_reader :properties
611
611
 
612
612
  ### Attribute Writers ###
613
- # @param values [Hash<String, Property>]
613
+ # @return [Hash<String, Property>]
614
614
  def properties=(values)
615
- @properties = values.transform_values do |value|
615
+ @properties = values&.transform_values do |value|
616
616
  Property.initialize_from_value(value)
617
617
  end
618
618
  end
@@ -669,57 +669,57 @@ module Schemas
669
669
  attr_reader :some_enum_with_default
670
670
 
671
671
  ### Attribute Accessors ###
672
- # @param value [String]
672
+ # @return [String]
673
673
  attr_accessor :test_id
674
- # @param value [Float]
674
+ # @return [Float]
675
675
  attr_accessor :test_float
676
- # @param values [Array<String>]
676
+ # @return [Array<String>]
677
677
  attr_accessor :test_string_array
678
- # @param values [Array<Integer>]
678
+ # @return [Array<Integer>]
679
679
  attr_accessor :test_int_array
680
- # @param value [Integer, nil]
680
+ # @return [Integer, nil]
681
681
  attr_accessor :test_optional_int
682
- # @param values [Hash<String, Integer>]
682
+ # @return [Hash<String, Integer>]
683
683
  attr_accessor :some_integer_map
684
684
 
685
685
  ### Attribute Writers ###
686
- # @param value [ARecord]
686
+ # @return [ARecord]
687
687
  def some_record=(value)
688
688
  @some_record = ARecord.initialize_from_value(value)
689
689
  end
690
690
 
691
- # @param value [nil, ARecord]
691
+ # @return [nil, ARecord]
692
692
  def some_optional_record=(value)
693
693
  @some_optional_record = ARecord.initialize_from_value(value)
694
694
  end
695
695
 
696
- # @param values [Array<ARecord>]
696
+ # @return [Array<ARecord>]
697
697
  def some_record_array=(values)
698
- @some_record_array = values.map do |value|
698
+ @some_record_array = values&.map do |value|
699
699
  ARecord.initialize_from_value(value)
700
700
  end
701
701
  end
702
702
 
703
- # @param values [Hash<String, ARecord>]
703
+ # @return [Hash<String, ARecord>]
704
704
  def some_record_map=(values)
705
- @some_record_map = values.transform_values do |value|
705
+ @some_record_map = values&.transform_values do |value|
706
706
  ARecord.initialize_from_value(value)
707
707
  end
708
708
  end
709
709
 
710
- # @param values [Array<AnEnum>]
710
+ # @return [Array<AnEnum>]
711
711
  def some_enum_array=(values)
712
- @some_enum_array = values.map do |value|
712
+ @some_enum_array = values&.map do |value|
713
713
  AnEnum.initialize_from_value(value)
714
714
  end
715
715
  end
716
716
 
717
- # @param value [nil, AnotherEnum]
717
+ # @return [nil, AnotherEnum]
718
718
  def some_optional_enum=(value)
719
719
  @some_optional_enum = AnotherEnum.initialize_from_value(value)
720
720
  end
721
721
 
722
- # @param value [YetAnotherEnum]
722
+ # @return [YetAnotherEnum]
723
723
  def some_enum_with_default=(value)
724
724
  @some_enum_with_default = YetAnotherEnum.initialize_from_value(value)
725
725
  end
@@ -764,6 +764,13 @@ module Schemas
764
764
  'com.my-namespace'
765
765
  end
766
766
 
767
+ def self.tombstone(key)
768
+ record = self.new
769
+ record.tombstone_key = key
770
+ record.a_string = key
771
+ record
772
+ end
773
+
767
774
  # @override
768
775
  def as_json(_opts={})
769
776
  {
@@ -796,15 +803,15 @@ module Schemas
796
803
  class MySchemaWithDateTime < Deimos::SchemaClass::Record
797
804
 
798
805
  ### Attribute Accessors ###
799
- # @param value [String]
806
+ # @return [String]
800
807
  attr_accessor :test_id
801
- # @param value [Integer, nil]
808
+ # @return [Integer, nil]
802
809
  attr_accessor :updated_at
803
- # @param value [nil, Integer]
810
+ # @return [nil, Integer]
804
811
  attr_accessor :some_int
805
- # @param value [nil, Integer]
812
+ # @return [nil, Integer]
806
813
  attr_accessor :some_datetime_int
807
- # @param value [String]
814
+ # @return [String]
808
815
  attr_accessor :timestamp
809
816
 
810
817
  # @override
@@ -855,13 +862,13 @@ module Schemas
855
862
  class MySchemaWithId < Deimos::SchemaClass::Record
856
863
 
857
864
  ### Attribute Accessors ###
858
- # @param value [String]
865
+ # @return [String]
859
866
  attr_accessor :test_id
860
- # @param value [Integer]
867
+ # @return [Integer]
861
868
  attr_accessor :some_int
862
- # @param value [String]
869
+ # @return [String]
863
870
  attr_accessor :message_id
864
- # @param value [String]
871
+ # @return [String]
865
872
  attr_accessor :timestamp
866
873
 
867
874
  # @override
@@ -909,15 +916,15 @@ module Schemas
909
916
  class MySchemaWithUniqueId < Deimos::SchemaClass::Record
910
917
 
911
918
  ### Attribute Accessors ###
912
- # @param value [Integer]
919
+ # @return [Integer]
913
920
  attr_accessor :id
914
- # @param value [String]
921
+ # @return [String]
915
922
  attr_accessor :test_id
916
- # @param value [Integer]
923
+ # @return [Integer]
917
924
  attr_accessor :some_int
918
- # @param value [String]
925
+ # @return [String]
919
926
  attr_accessor :message_id
920
- # @param value [String]
927
+ # @return [String]
921
928
  attr_accessor :timestamp
922
929
 
923
930
  # @override
@@ -968,7 +975,7 @@ module Schemas
968
975
  class Property < Deimos::SchemaClass::Record
969
976
 
970
977
  ### Attribute Accessors ###
971
- # @param value [Boolean, Integer, Integer, Float, Float, String, Array<Property>, Hash<String, Property>]
978
+ # @return [Boolean, Integer, Integer, Float, Float, String, Array<Property>, Hash<String, Property>]
972
979
  attr_accessor :property
973
980
 
974
981
  # @override
@@ -1007,7 +1014,7 @@ module Schemas
1007
1014
  class UpdateRequest < Deimos::SchemaClass::Record
1008
1015
 
1009
1016
  ### Attribute Accessors ###
1010
- # @param value [String]
1017
+ # @return [String]
1011
1018
  attr_accessor :update_request_id
1012
1019
 
1013
1020
  # @override
@@ -1046,7 +1053,7 @@ module Schemas
1046
1053
  class UpdateResponse < Deimos::SchemaClass::Record
1047
1054
 
1048
1055
  ### Attribute Accessors ###
1049
- # @param value [String]
1056
+ # @return [String]
1050
1057
  attr_accessor :update_response_id
1051
1058
 
1052
1059
  # @override
@@ -1085,23 +1092,23 @@ module Schemas
1085
1092
  class Wibble < Deimos::SchemaClass::Record
1086
1093
 
1087
1094
  ### Attribute Accessors ###
1088
- # @param value [Integer]
1095
+ # @return [Integer]
1089
1096
  attr_accessor :id
1090
- # @param value [Integer]
1097
+ # @return [Integer]
1091
1098
  attr_accessor :wibble_id
1092
- # @param value [String]
1099
+ # @return [String]
1093
1100
  attr_accessor :name
1094
- # @param value [String]
1101
+ # @return [String]
1095
1102
  attr_accessor :floop
1096
- # @param value [Integer]
1103
+ # @return [Integer]
1097
1104
  attr_accessor :birthday_int
1098
- # @param value [Integer]
1105
+ # @return [Integer]
1099
1106
  attr_accessor :birthday_long
1100
- # @param value [nil, Integer]
1107
+ # @return [nil, Integer]
1101
1108
  attr_accessor :birthday_optional
1102
- # @param value [Integer]
1109
+ # @return [Integer]
1103
1110
  attr_accessor :updated_at
1104
- # @param value [Integer]
1111
+ # @return [Integer]
1105
1112
  attr_accessor :created_at
1106
1113
 
1107
1114
  # @override
@@ -1164,15 +1171,15 @@ module Schemas
1164
1171
  class Widget < Deimos::SchemaClass::Record
1165
1172
 
1166
1173
  ### Attribute Accessors ###
1167
- # @param value [Integer]
1174
+ # @return [Integer]
1168
1175
  attr_accessor :id
1169
- # @param value [Integer]
1176
+ # @return [Integer]
1170
1177
  attr_accessor :widget_id
1171
- # @param value [String]
1178
+ # @return [String]
1172
1179
  attr_accessor :name
1173
- # @param value [Integer]
1180
+ # @return [Integer]
1174
1181
  attr_accessor :updated_at
1175
- # @param value [Integer]
1182
+ # @return [Integer]
1176
1183
  attr_accessor :created_at
1177
1184
 
1178
1185
  # @override
@@ -1223,15 +1230,15 @@ module Schemas
1223
1230
  class WidgetTheSecond < Deimos::SchemaClass::Record
1224
1231
 
1225
1232
  ### Attribute Accessors ###
1226
- # @param value [Integer]
1233
+ # @return [Integer]
1227
1234
  attr_accessor :id
1228
- # @param value [Integer]
1235
+ # @return [Integer]
1229
1236
  attr_accessor :widget_id
1230
- # @param value [String]
1237
+ # @return [String]
1231
1238
  attr_accessor :model_id
1232
- # @param value [Integer]
1239
+ # @return [Integer]
1233
1240
  attr_accessor :updated_at
1234
- # @param value [Integer]
1241
+ # @return [Integer]
1235
1242
  attr_accessor :created_at
1236
1243
 
1237
1244
  # @override