deimos-ruby 1.16.2 → 1.16.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/README.md +2 -0
  4. data/lib/deimos/schema_class/record.rb +7 -1
  5. data/lib/deimos/version.rb +1 -1
  6. data/lib/generators/deimos/schema_class/templates/schema_record.rb.tt +13 -5
  7. data/lib/generators/deimos/schema_class_generator.rb +40 -22
  8. data/regenerate_test_schema_classes.rb +68 -0
  9. data/spec/generators/schema_class/my_schema_spec.rb +16 -0
  10. data/spec/generators/schema_class/my_schema_with_circular_reference_spec.rb +1 -1
  11. data/spec/generators/schema_class/my_schema_with_complex_types_spec.rb +32 -24
  12. data/spec/producer_spec.rb +11 -11
  13. data/spec/schemas/{generated.rb → my_namespace/generated.rb} +28 -32
  14. data/spec/schemas/{my_nested_schema.rb → my_namespace/my_nested_schema.rb} +23 -16
  15. data/spec/schemas/{my_schema.rb → my_namespace/my_schema.rb} +12 -5
  16. data/spec/schemas/my_namespace/my_schema_compound_key.rb +41 -0
  17. data/spec/schemas/my_namespace/my_schema_id_key.rb +36 -0
  18. data/spec/schemas/{my_schema_key.rb → my_namespace/my_schema_key.rb} +3 -3
  19. data/spec/schemas/my_namespace/my_schema_with_boolean.rb +41 -0
  20. data/spec/schemas/{my_schema_with_circular_reference.rb → my_namespace/my_schema_with_circular_reference.rb} +15 -10
  21. data/spec/schemas/{my_schema_with_complex_type.rb → my_namespace/my_schema_with_complex_type.rb} +34 -49
  22. data/spec/schemas/my_namespace/my_schema_with_date_time.rb +56 -0
  23. data/spec/schemas/my_namespace/my_schema_with_id.rb +51 -0
  24. data/spec/schemas/my_namespace/my_schema_with_unique_id.rb +56 -0
  25. data/spec/schemas/my_namespace/wibble.rb +76 -0
  26. data/spec/schemas/my_namespace/widget.rb +56 -0
  27. data/spec/schemas/my_namespace/widget_the_second.rb +56 -0
  28. data/spec/schemas/request/create_topic.rb +36 -0
  29. data/spec/schemas/request/index.rb +36 -0
  30. data/spec/schemas/request/update_request.rb +36 -0
  31. data/spec/schemas/response/create_topic.rb +36 -0
  32. data/spec/schemas/response/index.rb +36 -0
  33. data/spec/schemas/response/update_response.rb +36 -0
  34. data/spec/snapshots/consumers-no-nest.snap +93 -86
  35. data/spec/snapshots/consumers.snap +94 -87
  36. data/spec/snapshots/consumers_and_producers-no-nest.snap +108 -87
  37. data/spec/snapshots/consumers_and_producers.snap +109 -88
  38. data/spec/snapshots/consumers_circular-no-nest.snap +93 -86
  39. data/spec/snapshots/consumers_circular.snap +94 -87
  40. data/spec/snapshots/consumers_complex_types-no-nest.snap +93 -86
  41. data/spec/snapshots/consumers_complex_types.snap +94 -87
  42. data/spec/snapshots/consumers_nested-no-nest.snap +93 -86
  43. data/spec/snapshots/consumers_nested.snap +94 -87
  44. data/spec/snapshots/namespace_folders.snap +111 -90
  45. data/spec/snapshots/producers_with_key-no-nest.snap +94 -87
  46. data/spec/snapshots/producers_with_key.snap +95 -88
  47. data/spec/spec_helper.rb +2 -1
  48. metadata +48 -15
@@ -8,7 +8,7 @@ module Schemas
8
8
  class CreateTopic < Deimos::SchemaClass::Record
9
9
 
10
10
  ### Attribute Accessors ###
11
- # @param value [String]
11
+ # @return [String]
12
12
  attr_accessor :response_id
13
13
 
14
14
  # @override
@@ -51,7 +51,7 @@ module Schemas
51
51
  class ARecord < Deimos::SchemaClass::Record
52
52
 
53
53
  ### Attribute Accessors ###
54
- # @param value [String]
54
+ # @return [String]
55
55
  attr_accessor :a_record_field
56
56
 
57
57
  # @override
@@ -97,34 +97,34 @@ module Schemas
97
97
  attr_reader :a_record
98
98
 
99
99
  ### Attribute Accessors ###
100
- # @param value [String]
100
+ # @return [String]
101
101
  attr_accessor :a_string
102
- # @param value [Integer]
102
+ # @return [Integer]
103
103
  attr_accessor :a_int
104
- # @param value [Integer]
104
+ # @return [Integer]
105
105
  attr_accessor :a_long
106
- # @param value [Float]
106
+ # @return [Float]
107
107
  attr_accessor :a_float
108
- # @param value [Float]
108
+ # @return [Float]
109
109
  attr_accessor :a_double
110
- # @param value [nil, Integer]
110
+ # @return [nil, Integer]
111
111
  attr_accessor :an_optional_int
112
- # @param values [Array<Integer>]
112
+ # @return [Array<Integer>]
113
113
  attr_accessor :an_array
114
- # @param values [Hash<String, String>]
114
+ # @return [Hash<String, String>]
115
115
  attr_accessor :a_map
116
- # @param value [String]
116
+ # @return [String]
117
117
  attr_accessor :timestamp
118
- # @param value [String]
118
+ # @return [String]
119
119
  attr_accessor :message_id
120
120
 
121
121
  ### Attribute Writers ###
122
- # @param value [AnEnum]
122
+ # @return [AnEnum]
123
123
  def an_enum=(value)
124
124
  @an_enum = AnEnum.initialize_from_value(value)
125
125
  end
126
126
 
127
- # @param value [ARecord]
127
+ # @return [ARecord]
128
128
  def a_record=(value)
129
129
  @a_record = ARecord.initialize_from_value(value)
130
130
  end
@@ -198,7 +198,7 @@ module Schemas
198
198
  class Index < Deimos::SchemaClass::Record
199
199
 
200
200
  ### Attribute Accessors ###
201
- # @param value [String]
201
+ # @return [String]
202
202
  attr_accessor :response_id
203
203
 
204
204
  # @override
@@ -241,13 +241,13 @@ module Schemas
241
241
  class MyNestedRecord < Deimos::SchemaClass::Record
242
242
 
243
243
  ### Attribute Accessors ###
244
- # @param value [Integer]
244
+ # @return [Integer]
245
245
  attr_accessor :some_int
246
- # @param value [Float]
246
+ # @return [Float]
247
247
  attr_accessor :some_float
248
- # @param value [String]
248
+ # @return [String]
249
249
  attr_accessor :some_string
250
- # @param value [nil, Integer]
250
+ # @return [nil, Integer]
251
251
  attr_accessor :some_optional_int
252
252
 
253
253
  # @override
@@ -291,20 +291,20 @@ module Schemas
291
291
  attr_reader :some_optional_record
292
292
 
293
293
  ### Attribute Accessors ###
294
- # @param value [String]
294
+ # @return [String]
295
295
  attr_accessor :test_id
296
- # @param value [Float]
296
+ # @return [Float]
297
297
  attr_accessor :test_float
298
- # @param values [Array<String>]
298
+ # @return [Array<String>]
299
299
  attr_accessor :test_array
300
300
 
301
301
  ### Attribute Writers ###
302
- # @param value [MyNestedRecord]
302
+ # @return [MyNestedRecord]
303
303
  def some_nested_record=(value)
304
304
  @some_nested_record = MyNestedRecord.initialize_from_value(value)
305
305
  end
306
306
 
307
- # @param value [nil, MyNestedRecord]
307
+ # @return [nil, MyNestedRecord]
308
308
  def some_optional_record=(value)
309
309
  @some_optional_record = MyNestedRecord.initialize_from_value(value)
310
310
  end
@@ -357,9 +357,9 @@ module Schemas
357
357
  class MySchema < Deimos::SchemaClass::Record
358
358
 
359
359
  ### Attribute Accessors ###
360
- # @param value [String]
360
+ # @return [String]
361
361
  attr_accessor :test_id
362
- # @param value [Integer]
362
+ # @return [Integer]
363
363
  attr_accessor :some_int
364
364
 
365
365
  # @override
@@ -401,9 +401,9 @@ module Schemas
401
401
  class MySchemaCompoundKey < Deimos::SchemaClass::Record
402
402
 
403
403
  ### Attribute Accessors ###
404
- # @param value [String]
404
+ # @return [String]
405
405
  attr_accessor :part_one
406
- # @param value [String]
406
+ # @return [String]
407
407
  attr_accessor :part_two
408
408
 
409
409
  # @override
@@ -445,7 +445,7 @@ module Schemas
445
445
  class MySchemaIdKey < Deimos::SchemaClass::Record
446
446
 
447
447
  ### Attribute Accessors ###
448
- # @param value [Integer]
448
+ # @return [Integer]
449
449
  attr_accessor :id
450
450
 
451
451
  # @override
@@ -484,7 +484,7 @@ module Schemas
484
484
  class MySchemaKey < Deimos::SchemaClass::Record
485
485
 
486
486
  ### Attribute Accessors ###
487
- # @param value [String]
487
+ # @return [String]
488
488
  attr_accessor :test_id
489
489
 
490
490
  # @override
@@ -523,9 +523,9 @@ module Schemas
523
523
  class MySchemaWithBoolean < Deimos::SchemaClass::Record
524
524
 
525
525
  ### Attribute Accessors ###
526
- # @param value [String]
526
+ # @return [String]
527
527
  attr_accessor :test_id
528
- # @param value [Boolean]
528
+ # @return [Boolean]
529
529
  attr_accessor :some_bool
530
530
 
531
531
  # @override
@@ -571,7 +571,7 @@ module Schemas
571
571
  class Property < Deimos::SchemaClass::Record
572
572
 
573
573
  ### Attribute Accessors ###
574
- # @param value [Boolean, Integer, Integer, Float, Float, String, Array<Property>, Hash<String, Property>]
574
+ # @return [Boolean, Integer, Integer, Float, Float, String, Array<Property>, Hash<String, Property>]
575
575
  attr_accessor :property
576
576
 
577
577
  # @override
@@ -604,9 +604,9 @@ module Schemas
604
604
  attr_reader :properties
605
605
 
606
606
  ### Attribute Writers ###
607
- # @param values [Hash<String, Property>]
607
+ # @return [Hash<String, Property>]
608
608
  def properties=(values)
609
- @properties = values.transform_values do |value|
609
+ @properties = values&.transform_values do |value|
610
610
  Property.initialize_from_value(value)
611
611
  end
612
612
  end
@@ -651,7 +651,7 @@ module Schemas
651
651
  class ARecord < Deimos::SchemaClass::Record
652
652
 
653
653
  ### Attribute Accessors ###
654
- # @param value [String]
654
+ # @return [String]
655
655
  attr_accessor :a_record_field
656
656
 
657
657
  # @override
@@ -729,57 +729,57 @@ module Schemas
729
729
  attr_reader :some_enum_with_default
730
730
 
731
731
  ### Attribute Accessors ###
732
- # @param value [String]
732
+ # @return [String]
733
733
  attr_accessor :test_id
734
- # @param value [Float]
734
+ # @return [Float]
735
735
  attr_accessor :test_float
736
- # @param values [Array<String>]
736
+ # @return [Array<String>]
737
737
  attr_accessor :test_string_array
738
- # @param values [Array<Integer>]
738
+ # @return [Array<Integer>]
739
739
  attr_accessor :test_int_array
740
- # @param value [Integer, nil]
740
+ # @return [Integer, nil]
741
741
  attr_accessor :test_optional_int
742
- # @param values [Hash<String, Integer>]
742
+ # @return [Hash<String, Integer>]
743
743
  attr_accessor :some_integer_map
744
744
 
745
745
  ### Attribute Writers ###
746
- # @param value [ARecord]
746
+ # @return [ARecord]
747
747
  def some_record=(value)
748
748
  @some_record = ARecord.initialize_from_value(value)
749
749
  end
750
750
 
751
- # @param value [nil, ARecord]
751
+ # @return [nil, ARecord]
752
752
  def some_optional_record=(value)
753
753
  @some_optional_record = ARecord.initialize_from_value(value)
754
754
  end
755
755
 
756
- # @param values [Array<ARecord>]
756
+ # @return [Array<ARecord>]
757
757
  def some_record_array=(values)
758
- @some_record_array = values.map do |value|
758
+ @some_record_array = values&.map do |value|
759
759
  ARecord.initialize_from_value(value)
760
760
  end
761
761
  end
762
762
 
763
- # @param values [Hash<String, ARecord>]
763
+ # @return [Hash<String, ARecord>]
764
764
  def some_record_map=(values)
765
- @some_record_map = values.transform_values do |value|
765
+ @some_record_map = values&.transform_values do |value|
766
766
  ARecord.initialize_from_value(value)
767
767
  end
768
768
  end
769
769
 
770
- # @param values [Array<AnEnum>]
770
+ # @return [Array<AnEnum>]
771
771
  def some_enum_array=(values)
772
- @some_enum_array = values.map do |value|
772
+ @some_enum_array = values&.map do |value|
773
773
  AnEnum.initialize_from_value(value)
774
774
  end
775
775
  end
776
776
 
777
- # @param value [nil, AnotherEnum]
777
+ # @return [nil, AnotherEnum]
778
778
  def some_optional_enum=(value)
779
779
  @some_optional_enum = AnotherEnum.initialize_from_value(value)
780
780
  end
781
781
 
782
- # @param value [YetAnotherEnum]
782
+ # @return [YetAnotherEnum]
783
783
  def some_enum_with_default=(value)
784
784
  @some_enum_with_default = YetAnotherEnum.initialize_from_value(value)
785
785
  end
@@ -824,6 +824,13 @@ module Schemas
824
824
  'com.my-namespace'
825
825
  end
826
826
 
827
+ def self.tombstone(key)
828
+ record = self.new
829
+ record.tombstone_key = key
830
+ record.a_string = key
831
+ record
832
+ end
833
+
827
834
  # @override
828
835
  def as_json(_opts={})
829
836
  {
@@ -856,15 +863,15 @@ module Schemas
856
863
  class MySchemaWithDateTime < Deimos::SchemaClass::Record
857
864
 
858
865
  ### Attribute Accessors ###
859
- # @param value [String]
866
+ # @return [String]
860
867
  attr_accessor :test_id
861
- # @param value [Integer, nil]
868
+ # @return [Integer, nil]
862
869
  attr_accessor :updated_at
863
- # @param value [nil, Integer]
870
+ # @return [nil, Integer]
864
871
  attr_accessor :some_int
865
- # @param value [nil, Integer]
872
+ # @return [nil, Integer]
866
873
  attr_accessor :some_datetime_int
867
- # @param value [String]
874
+ # @return [String]
868
875
  attr_accessor :timestamp
869
876
 
870
877
  # @override
@@ -915,13 +922,13 @@ module Schemas
915
922
  class MySchemaWithId < Deimos::SchemaClass::Record
916
923
 
917
924
  ### Attribute Accessors ###
918
- # @param value [String]
925
+ # @return [String]
919
926
  attr_accessor :test_id
920
- # @param value [Integer]
927
+ # @return [Integer]
921
928
  attr_accessor :some_int
922
- # @param value [String]
929
+ # @return [String]
923
930
  attr_accessor :message_id
924
- # @param value [String]
931
+ # @return [String]
925
932
  attr_accessor :timestamp
926
933
 
927
934
  # @override
@@ -969,15 +976,15 @@ module Schemas
969
976
  class MySchemaWithUniqueId < Deimos::SchemaClass::Record
970
977
 
971
978
  ### Attribute Accessors ###
972
- # @param value [Integer]
979
+ # @return [Integer]
973
980
  attr_accessor :id
974
- # @param value [String]
981
+ # @return [String]
975
982
  attr_accessor :test_id
976
- # @param value [Integer]
983
+ # @return [Integer]
977
984
  attr_accessor :some_int
978
- # @param value [String]
985
+ # @return [String]
979
986
  attr_accessor :message_id
980
- # @param value [String]
987
+ # @return [String]
981
988
  attr_accessor :timestamp
982
989
 
983
990
  # @override
@@ -1028,7 +1035,7 @@ module Schemas
1028
1035
  class UpdateRequest < Deimos::SchemaClass::Record
1029
1036
 
1030
1037
  ### Attribute Accessors ###
1031
- # @param value [String]
1038
+ # @return [String]
1032
1039
  attr_accessor :update_request_id
1033
1040
 
1034
1041
  # @override
@@ -1067,7 +1074,7 @@ module Schemas
1067
1074
  class UpdateResponse < Deimos::SchemaClass::Record
1068
1075
 
1069
1076
  ### Attribute Accessors ###
1070
- # @param value [String]
1077
+ # @return [String]
1071
1078
  attr_accessor :update_response_id
1072
1079
 
1073
1080
  # @override
@@ -1106,23 +1113,23 @@ module Schemas
1106
1113
  class Wibble < Deimos::SchemaClass::Record
1107
1114
 
1108
1115
  ### Attribute Accessors ###
1109
- # @param value [Integer]
1116
+ # @return [Integer]
1110
1117
  attr_accessor :id
1111
- # @param value [Integer]
1118
+ # @return [Integer]
1112
1119
  attr_accessor :wibble_id
1113
- # @param value [String]
1120
+ # @return [String]
1114
1121
  attr_accessor :name
1115
- # @param value [String]
1122
+ # @return [String]
1116
1123
  attr_accessor :floop
1117
- # @param value [Integer]
1124
+ # @return [Integer]
1118
1125
  attr_accessor :birthday_int
1119
- # @param value [Integer]
1126
+ # @return [Integer]
1120
1127
  attr_accessor :birthday_long
1121
- # @param value [nil, Integer]
1128
+ # @return [nil, Integer]
1122
1129
  attr_accessor :birthday_optional
1123
- # @param value [Integer]
1130
+ # @return [Integer]
1124
1131
  attr_accessor :updated_at
1125
- # @param value [Integer]
1132
+ # @return [Integer]
1126
1133
  attr_accessor :created_at
1127
1134
 
1128
1135
  # @override
@@ -1185,15 +1192,15 @@ module Schemas
1185
1192
  class Widget < Deimos::SchemaClass::Record
1186
1193
 
1187
1194
  ### Attribute Accessors ###
1188
- # @param value [Integer]
1195
+ # @return [Integer]
1189
1196
  attr_accessor :id
1190
- # @param value [Integer]
1197
+ # @return [Integer]
1191
1198
  attr_accessor :widget_id
1192
- # @param value [String]
1199
+ # @return [String]
1193
1200
  attr_accessor :name
1194
- # @param value [Integer]
1201
+ # @return [Integer]
1195
1202
  attr_accessor :updated_at
1196
- # @param value [Integer]
1203
+ # @return [Integer]
1197
1204
  attr_accessor :created_at
1198
1205
 
1199
1206
  # @override
@@ -1244,15 +1251,15 @@ module Schemas
1244
1251
  class WidgetTheSecond < Deimos::SchemaClass::Record
1245
1252
 
1246
1253
  ### Attribute Accessors ###
1247
- # @param value [Integer]
1254
+ # @return [Integer]
1248
1255
  attr_accessor :id
1249
- # @param value [Integer]
1256
+ # @return [Integer]
1250
1257
  attr_accessor :widget_id
1251
- # @param value [String]
1258
+ # @return [String]
1252
1259
  attr_accessor :model_id
1253
- # @param value [Integer]
1260
+ # @return [Integer]
1254
1261
  attr_accessor :updated_at
1255
- # @param value [Integer]
1262
+ # @return [Integer]
1256
1263
  attr_accessor :created_at
1257
1264
 
1258
1265
  # @override