rbs_rails 0.13.0 → 0.13.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7d71f04b224c69937d2e7c3fca24a085a5475ec09425baa810577d8dc403600
4
- data.tar.gz: b5e4959c6afaf50ac5c9569cb095ef52eb4c54b38a48083337c177297afb05e2
3
+ metadata.gz: 4a0fceffc94637dc5cfe4d2779a2431bed24c741a89576fea845e6d6f8718231
4
+ data.tar.gz: 535cdee761f44679a26717c43eaca2b1cbae235bd54854c6107829c26035a777
5
5
  SHA512:
6
- metadata.gz: 3f23018664d11f5bd9a94451830f0370e5f295bb0571ae5fc7927d7e8afe05a697bc0f51be10794924001319b8440aa0ab7ef0381f8d0df811ef8135a1162dd3
7
- data.tar.gz: 37725067cf0c61a72b173f7faad77381652f04a4f8948855c318d88022ae50b34cfb277369b3ca0bbb09c1be6be4fa553b1c40a8ae70acd52c5f2ab90237e933
6
+ metadata.gz: dfe9d07c72b951d2c87a6f2cadfcdffaada7699f1727215be76fabc119192193b2bb2742ca6c99a769b02dc2e5762b4cc67a0811889c831b5a345af20162431a
7
+ data.tar.gz: cf034e981312079f7de0879270c14084b43c8c95b18957627a9e16ccc9477dd3574c843a4d5494c8df4e48198e4a4584214979a71c779be581f21452f5f57fb5
data/CHANGELOG.md CHANGED
@@ -2,7 +2,23 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
- ## 0.13
5
+ ## 0.13.1
6
+
7
+ * Change enum method return type from void to untyped [#366](https://github.com/pocke/rbs_rails/pull/366)
8
+ * Fix enum methods generation to only include defined methods [#368](https://github.com/pocke/rbs_rails/pull/368)
9
+ * Remove stale sig/rbs_rails/utils directory [#367](https://github.com/pocke/rbs_rails/pull/367)
10
+ * Fix argument types for will_save_change_to_attribute method [#370](https://github.com/pocke/rbs_rails/pull/370)
11
+ * Add missing migration for label column on users table [#374](https://github.com/pocke/rbs_rails/pull/374)
12
+ * Add from: and to: keyword argument types to saved_change_to_<attr>? [#375](https://github.com/pocke/rbs_rails/pull/375)
13
+ * Support for composed_of aggregation RBS generation [#373](https://github.com/pocke/rbs_rails/pull/373)
14
+ * Fix belongs_to builder methods to accept optional argument [#380](https://github.com/pocke/rbs_rails/pull/380)
15
+ * Generate RBS signatures for accepts_nested_attributes_for setters [#381](https://github.com/pocke/rbs_rails/pull/381)
16
+ * Allow Integer and Symbol in enum attribute setter signatures [#379](https://github.com/pocke/rbs_rails/pull/379)
17
+ * Determine primary key types for has_many and has_and_belongs_to_many associations [#376](https://github.com/pocke/rbs_rails/pull/376)
18
+
19
+ ### Bug fixes
20
+
21
+ ## 0.13.0
6
22
 
7
23
  ### New features
8
24
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rbs_rails (0.13.0)
4
+ rbs_rails (0.13.1)
5
5
  parser
6
6
  prism
7
7
  rbs (>= 1)
@@ -9,66 +9,68 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- actioncable (7.2.2.2)
13
- actionpack (= 7.2.2.2)
14
- activesupport (= 7.2.2.2)
12
+ actioncable (7.2.3.1)
13
+ actionpack (= 7.2.3.1)
14
+ activesupport (= 7.2.3.1)
15
15
  nio4r (~> 2.0)
16
16
  websocket-driver (>= 0.6.1)
17
17
  zeitwerk (~> 2.6)
18
- actionmailbox (7.2.2.2)
19
- actionpack (= 7.2.2.2)
20
- activejob (= 7.2.2.2)
21
- activerecord (= 7.2.2.2)
22
- activestorage (= 7.2.2.2)
23
- activesupport (= 7.2.2.2)
18
+ actionmailbox (7.2.3.1)
19
+ actionpack (= 7.2.3.1)
20
+ activejob (= 7.2.3.1)
21
+ activerecord (= 7.2.3.1)
22
+ activestorage (= 7.2.3.1)
23
+ activesupport (= 7.2.3.1)
24
24
  mail (>= 2.8.0)
25
- actionmailer (7.2.2.2)
26
- actionpack (= 7.2.2.2)
27
- actionview (= 7.2.2.2)
28
- activejob (= 7.2.2.2)
29
- activesupport (= 7.2.2.2)
25
+ actionmailer (7.2.3.1)
26
+ actionpack (= 7.2.3.1)
27
+ actionview (= 7.2.3.1)
28
+ activejob (= 7.2.3.1)
29
+ activesupport (= 7.2.3.1)
30
30
  mail (>= 2.8.0)
31
31
  rails-dom-testing (~> 2.2)
32
- actionpack (7.2.2.2)
33
- actionview (= 7.2.2.2)
34
- activesupport (= 7.2.2.2)
32
+ actionpack (7.2.3.1)
33
+ actionview (= 7.2.3.1)
34
+ activesupport (= 7.2.3.1)
35
+ cgi
35
36
  nokogiri (>= 1.8.5)
36
37
  racc
37
- rack (>= 2.2.4, < 3.2)
38
+ rack (>= 2.2.4, < 3.3)
38
39
  rack-session (>= 1.0.1)
39
40
  rack-test (>= 0.6.3)
40
41
  rails-dom-testing (~> 2.2)
41
42
  rails-html-sanitizer (~> 1.6)
42
43
  useragent (~> 0.16)
43
- actiontext (7.2.2.2)
44
- actionpack (= 7.2.2.2)
45
- activerecord (= 7.2.2.2)
46
- activestorage (= 7.2.2.2)
47
- activesupport (= 7.2.2.2)
44
+ actiontext (7.2.3.1)
45
+ actionpack (= 7.2.3.1)
46
+ activerecord (= 7.2.3.1)
47
+ activestorage (= 7.2.3.1)
48
+ activesupport (= 7.2.3.1)
48
49
  globalid (>= 0.6.0)
49
50
  nokogiri (>= 1.8.5)
50
- actionview (7.2.2.2)
51
- activesupport (= 7.2.2.2)
51
+ actionview (7.2.3.1)
52
+ activesupport (= 7.2.3.1)
52
53
  builder (~> 3.1)
54
+ cgi
53
55
  erubi (~> 1.11)
54
56
  rails-dom-testing (~> 2.2)
55
57
  rails-html-sanitizer (~> 1.6)
56
- activejob (7.2.2.2)
57
- activesupport (= 7.2.2.2)
58
+ activejob (7.2.3.1)
59
+ activesupport (= 7.2.3.1)
58
60
  globalid (>= 0.3.6)
59
- activemodel (7.2.2.2)
60
- activesupport (= 7.2.2.2)
61
- activerecord (7.2.2.2)
62
- activemodel (= 7.2.2.2)
63
- activesupport (= 7.2.2.2)
61
+ activemodel (7.2.3.1)
62
+ activesupport (= 7.2.3.1)
63
+ activerecord (7.2.3.1)
64
+ activemodel (= 7.2.3.1)
65
+ activesupport (= 7.2.3.1)
64
66
  timeout (>= 0.4.0)
65
- activestorage (7.2.2.2)
66
- actionpack (= 7.2.2.2)
67
- activejob (= 7.2.2.2)
68
- activerecord (= 7.2.2.2)
69
- activesupport (= 7.2.2.2)
67
+ activestorage (7.2.3.1)
68
+ actionpack (= 7.2.3.1)
69
+ activejob (= 7.2.3.1)
70
+ activerecord (= 7.2.3.1)
71
+ activesupport (= 7.2.3.1)
70
72
  marcel (~> 1.0)
71
- activesupport (7.2.2.2)
73
+ activesupport (7.2.3.1)
72
74
  base64
73
75
  benchmark (>= 0.3)
74
76
  bigdecimal
@@ -77,16 +79,17 @@ GEM
77
79
  drb
78
80
  i18n (>= 1.6, < 2)
79
81
  logger (>= 1.4.2)
80
- minitest (>= 5.1)
82
+ minitest (>= 5.1, < 6)
81
83
  securerandom (>= 0.3)
82
84
  tzinfo (~> 2.0, >= 2.0.5)
83
85
  ast (2.4.3)
84
86
  base64 (0.3.0)
85
- benchmark (0.4.1)
86
- bigdecimal (3.2.2)
87
+ benchmark (0.5.0)
88
+ bigdecimal (4.0.1)
87
89
  builder (3.3.0)
88
- concurrent-ruby (1.3.5)
89
- connection_pool (2.5.3)
90
+ cgi (0.5.1)
91
+ concurrent-ruby (1.3.6)
92
+ connection_pool (3.0.2)
90
93
  crass (1.0.6)
91
94
  csv (3.3.4)
92
95
  date (3.4.1)
@@ -96,7 +99,7 @@ GEM
96
99
  fileutils (1.7.3)
97
100
  globalid (1.2.1)
98
101
  activesupport (>= 6.1)
99
- i18n (1.14.7)
102
+ i18n (1.14.8)
100
103
  concurrent-ruby (~> 1.0)
101
104
  io-console (0.7.2)
102
105
  irb (1.14.1)
@@ -133,7 +136,7 @@ GEM
133
136
  net-smtp (0.5.0)
134
137
  net-protocol
135
138
  nio4r (2.7.4)
136
- nokogiri (1.18.9)
139
+ nokogiri (1.19.1)
137
140
  mini_portile2 (~> 2.8.2)
138
141
  racc (~> 1.4)
139
142
  parser (3.3.8.0)
@@ -143,28 +146,28 @@ GEM
143
146
  psych (5.1.2)
144
147
  stringio
145
148
  racc (1.8.1)
146
- rack (3.1.18)
147
- rack-session (2.1.1)
149
+ rack (3.2.6)
150
+ rack-session (2.1.2)
148
151
  base64 (>= 0.1.0)
149
152
  rack (>= 3.0.0)
150
153
  rack-test (2.2.0)
151
154
  rack (>= 1.3)
152
155
  rackup (2.2.0)
153
156
  rack (>= 3)
154
- rails (7.2.2.2)
155
- actioncable (= 7.2.2.2)
156
- actionmailbox (= 7.2.2.2)
157
- actionmailer (= 7.2.2.2)
158
- actionpack (= 7.2.2.2)
159
- actiontext (= 7.2.2.2)
160
- actionview (= 7.2.2.2)
161
- activejob (= 7.2.2.2)
162
- activemodel (= 7.2.2.2)
163
- activerecord (= 7.2.2.2)
164
- activestorage (= 7.2.2.2)
165
- activesupport (= 7.2.2.2)
157
+ rails (7.2.3.1)
158
+ actioncable (= 7.2.3.1)
159
+ actionmailbox (= 7.2.3.1)
160
+ actionmailer (= 7.2.3.1)
161
+ actionpack (= 7.2.3.1)
162
+ actiontext (= 7.2.3.1)
163
+ actionview (= 7.2.3.1)
164
+ activejob (= 7.2.3.1)
165
+ activemodel (= 7.2.3.1)
166
+ activerecord (= 7.2.3.1)
167
+ activestorage (= 7.2.3.1)
168
+ activesupport (= 7.2.3.1)
166
169
  bundler (>= 1.15.0)
167
- railties (= 7.2.2.2)
170
+ railties (= 7.2.3.1)
168
171
  rails-dom-testing (2.3.0)
169
172
  activesupport (>= 5.0.0)
170
173
  minitest
@@ -172,13 +175,15 @@ GEM
172
175
  rails-html-sanitizer (1.6.2)
173
176
  loofah (~> 2.21)
174
177
  nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
175
- railties (7.2.2.2)
176
- actionpack (= 7.2.2.2)
177
- activesupport (= 7.2.2.2)
178
+ railties (7.2.3.1)
179
+ actionpack (= 7.2.3.1)
180
+ activesupport (= 7.2.3.1)
181
+ cgi
178
182
  irb (~> 1.13)
179
183
  rackup (>= 1.0.0)
180
184
  rake (>= 12.2)
181
185
  thor (~> 1.0, >= 1.2.2)
186
+ tsort (>= 0.2)
182
187
  zeitwerk (~> 2.6)
183
188
  rainbow (3.1.1)
184
189
  rake (13.2.1)
data/README.md CHANGED
@@ -73,7 +73,7 @@ RbsRails.configure do |config|
73
73
  # Enable or disable checking for database migrations.
74
74
  # If enabled, rbs_rails stops to generate RBS files if database is not migrated to the latest version.
75
75
  # Default: enabled
76
- check_db_migrations = true
76
+ config.check_db_migrations = true
77
77
 
78
78
  # Define which models should be ignored during generation
79
79
  config.ignore_model_if do |klass|
data/example/rbs_rails.rb CHANGED
@@ -10,7 +10,7 @@ RbsRails.configure do |config|
10
10
  # Enable or disable checking for database migrations.
11
11
  # If enabled, rbs_rails stops to generate RBS files if database is not migrated to the latest version.
12
12
  # Default: enabled
13
- check_db_migrations = true
13
+ config.check_db_migrations = true
14
14
 
15
15
  # Define a proc to determine which models should be ignored during generation
16
16
  # The proc receives a model class and should return true if the model should be ignored
@@ -12,8 +12,8 @@ module RbsRails
12
12
  #
13
13
  # @enum_definitions: enum_definitions
14
14
 
15
- def enum(*args, **options) #: void
16
- super # steep:ignore
15
+ def enum(*args, **options) #: untyped
16
+ result = super # steep:ignore
17
17
 
18
18
  name, values = args #: [Symbol, Array[Symbol]?]
19
19
  if values
@@ -29,6 +29,8 @@ module RbsRails
29
29
 
30
30
  @enum_definitions ||= [] #: enum_definitions
31
31
  @enum_definitions&.append([definitions, options])
32
+
33
+ result
32
34
  end
33
35
 
34
36
  def enum_definitions #: Array[[Symbol, String]]
@@ -47,6 +47,7 @@ module RbsRails
47
47
  #{columns}
48
48
  #{alias_columns}
49
49
  #{associations}
50
+ #{composed_of_aggregations}
50
51
  #{generated_association_methods}
51
52
  #{has_secure_password}
52
53
  #{delegated_type_instance}
@@ -67,7 +68,7 @@ module RbsRails
67
68
  RBS
68
69
  end
69
70
 
70
- private def pk_type #: String
71
+ private def pk_type_for(klass) #: String
71
72
  pk = klass.primary_key
72
73
  return 'top' unless pk
73
74
 
@@ -83,6 +84,10 @@ module RbsRails
83
84
  end
84
85
  end
85
86
 
87
+ private def pk_type #: String
88
+ pk_type_for(klass)
89
+ end
90
+
86
91
  private def generated_relation_methods_decl #: String
87
92
  <<~RBS
88
93
  module #{generated_relation_methods_name}
@@ -169,12 +174,13 @@ module RbsRails
169
174
  type = Util.module_name(a.klass)
170
175
  collection_type = "#{type}::ActiveRecord_Associations_CollectionProxy"
171
176
  @dependencies << collection_type
177
+ association_pk_type = pk_type_for(a.klass)
172
178
 
173
179
  <<~RUBY.chomp
174
180
  def #{a.name}: () -> #{collection_type}
175
181
  def #{a.name}=: (#{collection_type} | ::Array[#{type}]) -> (#{collection_type} | ::Array[#{type}])
176
- def #{singular_name}_ids: () -> ::Array[::Integer]
177
- def #{singular_name}_ids=: (::Array[::Integer]) -> ::Array[::Integer]
182
+ def #{singular_name}_ids: () -> ::Array[#{association_pk_type}]
183
+ def #{singular_name}_ids=: (::Array[#{association_pk_type}]) -> ::Array[#{association_pk_type}]
178
184
  RUBY
179
185
  end.join("\n")
180
186
  end
@@ -187,12 +193,13 @@ module RbsRails
187
193
  type = Util.module_name(a.klass)
188
194
  collection_type = "#{type}::ActiveRecord_Associations_CollectionProxy"
189
195
  @dependencies << collection_type
196
+ association_pk_type = pk_type_for(a.klass)
190
197
 
191
198
  <<~RUBY.chomp
192
199
  def #{a.name}: () -> #{collection_type}
193
200
  def #{a.name}=: (#{collection_type} | ::Array[#{type}]) -> (#{collection_type} | ::Array[#{type}])
194
- def #{singular_name}_ids: () -> ::Array[::Integer]
195
- def #{singular_name}_ids=: (::Array[::Integer]) -> ::Array[::Integer]
201
+ def #{singular_name}_ids: () -> ::Array[#{association_pk_type}]
202
+ def #{singular_name}_ids=: (::Array[#{association_pk_type}]) -> ::Array[#{association_pk_type}]
196
203
  RUBY
197
204
  end.join("\n")
198
205
  end
@@ -228,21 +235,58 @@ module RbsRails
228
235
  methods << "def #{a.name}=: (#{type_optional}) -> #{type_optional}"
229
236
  methods << "def reload_#{a.name}: () -> #{type_optional}"
230
237
  if !a.polymorphic?
231
- methods << "def build_#{a.name}: (untyped) -> #{type}"
232
- methods << "def create_#{a.name}: (untyped) -> #{type}"
233
- methods << "def create_#{a.name}!: (untyped) -> #{type}"
238
+ methods << "def build_#{a.name}: (?untyped) -> #{type}"
239
+ methods << "def create_#{a.name}: (?untyped) -> #{type}"
240
+ methods << "def create_#{a.name}!: (?untyped) -> #{type}"
234
241
  end
235
242
  methods.join("\n")
236
243
  end.join("\n")
237
244
  end
238
245
 
246
+ private def composed_of_aggregations #: String
247
+ klass.reflect_on_all_aggregations.map do |a|
248
+ type = Util.module_name(a.klass)
249
+ @dependencies << a.klass.name
250
+ if a.options[:allow_nil]
251
+ type_optional = optional(type)
252
+ <<~RUBY.chomp
253
+ def #{a.name}: () -> #{type_optional}
254
+ def #{a.name}=: (#{type_optional}) -> #{type_optional}
255
+ RUBY
256
+ else
257
+ <<~RUBY.chomp
258
+ def #{a.name}: () -> #{type}
259
+ def #{a.name}=: (#{type}) -> #{type}
260
+ RUBY
261
+ end
262
+ end.join("\n")
263
+ end
264
+
265
+ private def nested_attributes_methods #: String?
266
+ return if klass.nested_attributes_options.empty?
267
+
268
+ klass.nested_attributes_options.each_key.map do |association_name|
269
+ reflection = klass.reflect_on_association(association_name)
270
+ next unless reflection
271
+
272
+ setter_name = "#{association_name}_attributes="
273
+ if reflection.collection?
274
+ "def #{setter_name}: (Hash[untyped, untyped] | Array[Hash[untyped, untyped]]) -> void"
275
+ else
276
+ "def #{setter_name}: (Hash[untyped, untyped]) -> void"
277
+ end
278
+ end.compact.join("\n")
279
+ end
280
+
239
281
  private def generated_association_methods #: String
240
- # @type var sigs: Array[String]
282
+ # @type var sigs: Array[String?]
241
283
  sigs = []
242
284
 
285
+ sigs << "module #{klass_name}::GeneratedAssociationMethods"
286
+ sigs << nested_attributes_methods
287
+
243
288
  # Needs to require "active_storage/engine"
244
289
  if klass.respond_to?(:attachment_reflections)
245
- sigs << "module #{klass_name}::GeneratedAssociationMethods"
246
290
  sigs << klass.attachment_reflections.map do |name, reflection|
247
291
  case reflection.macro
248
292
  when :has_one_attached
@@ -264,11 +308,12 @@ module RbsRails
264
308
  raise "unknown macro: #{reflection.macro}"
265
309
  end
266
310
  end.join("\n")
267
- sigs << "end"
268
- sigs << "include #{klass_name}::GeneratedAssociationMethods"
269
311
  end
270
312
 
271
- sigs.join("\n")
313
+ sigs << "end"
314
+ sigs << "include #{klass_name}::GeneratedAssociationMethods"
315
+
316
+ sigs.compact.join("\n")
272
317
  end
273
318
 
274
319
  # @rbs singleton: bool
@@ -376,9 +421,13 @@ module RbsRails
376
421
  private def enum_instance_methods #: String
377
422
  # @type var methods: Array[String]
378
423
  methods = []
379
- klass.enum_definitions.each do |_, method_name|
380
- methods << "def #{method_name}!: () -> bool"
381
- methods << "def #{method_name}?: () -> bool"
424
+ defined_methods = klass.instance_methods.to_set
425
+ klass.enum_definitions.each do |_, enum_method_name|
426
+ ["#{enum_method_name}!", "#{enum_method_name}?"].each do |method_name|
427
+ if defined_methods.member?(method_name.to_sym)
428
+ methods << "def #{method_name}: () -> bool"
429
+ end
430
+ end
382
431
  end
383
432
 
384
433
  methods.join("\n")
@@ -388,14 +437,21 @@ module RbsRails
388
437
  private def enum_class_methods(singleton:) #: String
389
438
  # @type var methods: Array[String]
390
439
  methods = []
440
+ defined_methods = klass.methods.to_set
391
441
  klass.enum_definitions.map(&:first).uniq.each do |name|
392
442
  column = klass.columns_hash[name.to_s] || klass.columns_hash[klass.attribute_aliases[name.to_s]]
393
443
  class_name = sql_type_to_class(column.type)
394
- methods << "def #{singleton ? 'self.' : ''}#{name.to_s.pluralize}: () -> ::ActiveSupport::HashWithIndifferentAccess[::String, #{class_name}]"
444
+ method_name = "#{name.to_s.pluralize}"
445
+ if defined_methods.member?(method_name.to_sym)
446
+ methods << "def #{singleton ? 'self.' : ''}#{method_name}: () -> ::ActiveSupport::HashWithIndifferentAccess[::String, #{class_name}]"
447
+ end
395
448
  end
396
- klass.enum_definitions.each do |_, method_name|
397
- methods << "def #{singleton ? 'self.' : ''}#{method_name}: () -> #{relation_class_name}"
398
- methods << "def #{singleton ? 'self.' : ''}not_#{method_name}: () -> #{relation_class_name}"
449
+ klass.enum_definitions.each do |_, enum_method_name|
450
+ ["#{enum_method_name}", "not_#{enum_method_name}"].each do |method_name|
451
+ if defined_methods.member?(method_name.to_sym)
452
+ methods << "def #{singleton ? 'self.' : ''}#{method_name}: () -> #{relation_class_name}"
453
+ end
454
+ end
399
455
  end
400
456
  methods.join("\n")
401
457
  end
@@ -532,6 +588,8 @@ module RbsRails
532
588
  # if your model has `serialize ..., Array`
533
589
  # etc.
534
590
  col_serialize_to = col_serializer.try(:object_class)&.name
591
+
592
+ col_is_enum = klass.enum_definitions.any? { |name, _| name == col.name.to_sym }
535
593
  if col_serializer.is_a?(Class) && col_serializer.name == 'ActiveRecord::Coders::JSON'
536
594
  class_name = 'untyped' # JSON
537
595
  elsif col_serialize_to == 'Array'
@@ -539,7 +597,7 @@ module RbsRails
539
597
  elsif col_serialize_to == 'Hash'
540
598
  class_name = '::Hash[untyped, untyped]' # Hash
541
599
  else
542
- class_name = if klass.enum_definitions.any? { |name, _| name == col.name.to_sym }
600
+ class_name = if col_is_enum
543
601
  '::String'
544
602
  else
545
603
  sql_type_to_class(col.type)
@@ -551,9 +609,14 @@ module RbsRails
551
609
  class_name_opt = (class_name == 'untyped') ? 'untyped' : optional(class_name)
552
610
  column_type = col.null ? class_name_opt : class_name
553
611
  sql_column_type = col.null ? optional(sql_class_name) : sql_class_name
612
+ arg_type = if col_is_enum
613
+ [sql_class_name, column_type, '::Symbol'].uniq.join('|')
614
+ else
615
+ column_type
616
+ end
554
617
  sig = <<~EOS
555
618
  def #{col.name}: () -> #{column_type}
556
- def #{col.name}=: (#{column_type}) -> #{column_type}
619
+ def #{col.name}=: (#{arg_type}) -> #{column_type}
557
620
  def #{col.name}?: () -> bool
558
621
  def #{col.name}_changed?: (?from: #{class_name_opt}, ?to: #{class_name_opt}) -> bool
559
622
  def #{col.name}_change: () -> [#{class_name_opt}, #{class_name_opt}]
@@ -566,8 +629,8 @@ module RbsRails
566
629
  def #{col.name}_change_to_be_saved: () -> ::Array[#{class_name_opt}]?
567
630
  def #{col.name}_in_database: () -> #{class_name_opt}
568
631
  def saved_change_to_#{col.name}: () -> ::Array[#{class_name_opt}]?
569
- def saved_change_to_#{col.name}?: () -> bool
570
- def will_save_change_to_#{col.name}?: () -> bool
632
+ def saved_change_to_#{col.name}?: (?from: #{class_name_opt}, ?to: #{class_name_opt}) -> bool
633
+ def will_save_change_to_#{col.name}?: (?from: #{class_name_opt}, ?to: #{class_name_opt}) -> bool
571
634
  def restore_#{col.name}!: () -> void
572
635
  def clear_#{col.name}_change: () -> void
573
636
  def #{col.name}_before_type_cast: () -> #{sql_column_type}
@@ -20,7 +20,7 @@ module RbsRails
20
20
  # @signature_root_dir: Pathname?
21
21
  # @ignore_model_if: (^(singleton(ActiveRecord::Base)) -> bool)?
22
22
 
23
- attr_reader :check_db_migrations #: bool
23
+ attr_accessor :check_db_migrations #: bool
24
24
 
25
25
  def initialize #: void
26
26
  @signature_root_dir = nil
@@ -2,5 +2,5 @@ module RbsRails
2
2
  # Because of copy_signatures is defined by lib/rbs_rails.rb
3
3
  # @dynamic self.copy_signatures
4
4
 
5
- VERSION = "0.13.0" #: String
5
+ VERSION = "0.13.1" #: String
6
6
  end
@@ -6,7 +6,7 @@ gems:
6
6
  source:
7
7
  type: git
8
8
  name: ruby/gem_rbs_collection
9
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
9
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
10
10
  remote: https://github.com/ruby/gem_rbs_collection.git
11
11
  repo_dir: gems
12
12
  - name: actionmailer
@@ -14,7 +14,7 @@ gems:
14
14
  source:
15
15
  type: git
16
16
  name: ruby/gem_rbs_collection
17
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
17
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
18
18
  remote: https://github.com/ruby/gem_rbs_collection.git
19
19
  repo_dir: gems
20
20
  - name: actionpack
@@ -22,7 +22,7 @@ gems:
22
22
  source:
23
23
  type: git
24
24
  name: ruby/gem_rbs_collection
25
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
25
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
26
26
  remote: https://github.com/ruby/gem_rbs_collection.git
27
27
  repo_dir: gems
28
28
  - name: actiontext
@@ -30,7 +30,7 @@ gems:
30
30
  source:
31
31
  type: git
32
32
  name: ruby/gem_rbs_collection
33
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
33
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
34
34
  remote: https://github.com/ruby/gem_rbs_collection.git
35
35
  repo_dir: gems
36
36
  - name: actionview
@@ -38,7 +38,7 @@ gems:
38
38
  source:
39
39
  type: git
40
40
  name: ruby/gem_rbs_collection
41
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
41
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
42
42
  remote: https://github.com/ruby/gem_rbs_collection.git
43
43
  repo_dir: gems
44
44
  - name: activejob
@@ -46,7 +46,7 @@ gems:
46
46
  source:
47
47
  type: git
48
48
  name: ruby/gem_rbs_collection
49
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
49
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
50
50
  remote: https://github.com/ruby/gem_rbs_collection.git
51
51
  repo_dir: gems
52
52
  - name: activemodel
@@ -54,7 +54,7 @@ gems:
54
54
  source:
55
55
  type: git
56
56
  name: ruby/gem_rbs_collection
57
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
57
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
58
58
  remote: https://github.com/ruby/gem_rbs_collection.git
59
59
  repo_dir: gems
60
60
  - name: activerecord
@@ -62,7 +62,7 @@ gems:
62
62
  source:
63
63
  type: git
64
64
  name: ruby/gem_rbs_collection
65
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
65
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
66
66
  remote: https://github.com/ruby/gem_rbs_collection.git
67
67
  repo_dir: gems
68
68
  - name: activestorage
@@ -70,7 +70,7 @@ gems:
70
70
  source:
71
71
  type: git
72
72
  name: ruby/gem_rbs_collection
73
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
73
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
74
74
  remote: https://github.com/ruby/gem_rbs_collection.git
75
75
  repo_dir: gems
76
76
  - name: activesupport
@@ -78,7 +78,7 @@ gems:
78
78
  source:
79
79
  type: git
80
80
  name: ruby/gem_rbs_collection
81
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
81
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
82
82
  remote: https://github.com/ruby/gem_rbs_collection.git
83
83
  repo_dir: gems
84
84
  - name: ast
@@ -86,7 +86,7 @@ gems:
86
86
  source:
87
87
  type: git
88
88
  name: ruby/gem_rbs_collection
89
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
89
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
90
90
  remote: https://github.com/ruby/gem_rbs_collection.git
91
91
  repo_dir: gems
92
92
  - name: base64
@@ -102,7 +102,7 @@ gems:
102
102
  source:
103
103
  type: git
104
104
  name: ruby/gem_rbs_collection
105
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
105
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
106
106
  remote: https://github.com/ruby/gem_rbs_collection.git
107
107
  repo_dir: gems
108
108
  - name: cgi
@@ -114,7 +114,7 @@ gems:
114
114
  source:
115
115
  type: git
116
116
  name: ruby/gem_rbs_collection
117
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
117
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
118
118
  remote: https://github.com/ruby/gem_rbs_collection.git
119
119
  repo_dir: gems
120
120
  - name: connection_pool
@@ -122,17 +122,13 @@ gems:
122
122
  source:
123
123
  type: git
124
124
  name: ruby/gem_rbs_collection
125
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
125
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
126
126
  remote: https://github.com/ruby/gem_rbs_collection.git
127
127
  repo_dir: gems
128
128
  - name: date
129
129
  version: '0'
130
130
  source:
131
131
  type: stdlib
132
- - name: dbm
133
- version: '0'
134
- source:
135
- type: stdlib
136
132
  - name: delegate
137
133
  version: '0'
138
134
  source:
@@ -158,7 +154,7 @@ gems:
158
154
  source:
159
155
  type: git
160
156
  name: ruby/gem_rbs_collection
161
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
157
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
162
158
  remote: https://github.com/ruby/gem_rbs_collection.git
163
159
  repo_dir: gems
164
160
  - name: i18n
@@ -166,7 +162,7 @@ gems:
166
162
  source:
167
163
  type: git
168
164
  name: ruby/gem_rbs_collection
169
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
165
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
170
166
  remote: https://github.com/ruby/gem_rbs_collection.git
171
167
  repo_dir: gems
172
168
  - name: io-console
@@ -178,15 +174,19 @@ gems:
178
174
  source:
179
175
  type: stdlib
180
176
  - name: logger
181
- version: '0'
177
+ version: '1.7'
182
178
  source:
183
- type: stdlib
179
+ type: git
180
+ name: ruby/gem_rbs_collection
181
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
182
+ remote: https://github.com/ruby/gem_rbs_collection.git
183
+ repo_dir: gems
184
184
  - name: mail
185
185
  version: '2.8'
186
186
  source:
187
187
  type: git
188
188
  name: ruby/gem_rbs_collection
189
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
189
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
190
190
  remote: https://github.com/ruby/gem_rbs_collection.git
191
191
  repo_dir: gems
192
192
  - name: marcel
@@ -194,7 +194,7 @@ gems:
194
194
  source:
195
195
  type: git
196
196
  name: ruby/gem_rbs_collection
197
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
197
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
198
198
  remote: https://github.com/ruby/gem_rbs_collection.git
199
199
  repo_dir: gems
200
200
  - name: mini_mime
@@ -202,7 +202,7 @@ gems:
202
202
  source:
203
203
  type: git
204
204
  name: ruby/gem_rbs_collection
205
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
205
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
206
206
  remote: https://github.com/ruby/gem_rbs_collection.git
207
207
  repo_dir: gems
208
208
  - name: minitest
@@ -210,7 +210,7 @@ gems:
210
210
  source:
211
211
  type: git
212
212
  name: ruby/gem_rbs_collection
213
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
213
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
214
214
  remote: https://github.com/ruby/gem_rbs_collection.git
215
215
  repo_dir: gems
216
216
  - name: monitor
@@ -226,7 +226,7 @@ gems:
226
226
  source:
227
227
  type: git
228
228
  name: ruby/gem_rbs_collection
229
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
229
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
230
230
  remote: https://github.com/ruby/gem_rbs_collection.git
231
231
  repo_dir: gems
232
232
  - name: nokogiri
@@ -234,7 +234,7 @@ gems:
234
234
  source:
235
235
  type: git
236
236
  name: ruby/gem_rbs_collection
237
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
237
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
238
238
  remote: https://github.com/ruby/gem_rbs_collection.git
239
239
  repo_dir: gems
240
240
  - name: openssl
@@ -250,7 +250,7 @@ gems:
250
250
  source:
251
251
  type: git
252
252
  name: ruby/gem_rbs_collection
253
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
253
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
254
254
  remote: https://github.com/ruby/gem_rbs_collection.git
255
255
  repo_dir: gems
256
256
  - name: pathname
@@ -261,20 +261,12 @@ gems:
261
261
  version: 1.2.0
262
262
  source:
263
263
  type: rubygems
264
- - name: pstore
265
- version: '0'
266
- source:
267
- type: stdlib
268
- - name: psych
269
- version: '0'
270
- source:
271
- type: stdlib
272
264
  - name: rack
273
265
  version: '2.2'
274
266
  source:
275
267
  type: git
276
268
  name: ruby/gem_rbs_collection
277
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
269
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
278
270
  remote: https://github.com/ruby/gem_rbs_collection.git
279
271
  repo_dir: gems
280
272
  - name: rails-dom-testing
@@ -282,7 +274,7 @@ gems:
282
274
  source:
283
275
  type: git
284
276
  name: ruby/gem_rbs_collection
285
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
277
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
286
278
  remote: https://github.com/ruby/gem_rbs_collection.git
287
279
  repo_dir: gems
288
280
  - name: rails-html-sanitizer
@@ -290,7 +282,7 @@ gems:
290
282
  source:
291
283
  type: git
292
284
  name: ruby/gem_rbs_collection
293
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
285
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
294
286
  remote: https://github.com/ruby/gem_rbs_collection.git
295
287
  repo_dir: gems
296
288
  - name: railties
@@ -298,7 +290,7 @@ gems:
298
290
  source:
299
291
  type: git
300
292
  name: ruby/gem_rbs_collection
301
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
293
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
302
294
  remote: https://github.com/ruby/gem_rbs_collection.git
303
295
  repo_dir: gems
304
296
  - name: rake
@@ -306,11 +298,11 @@ gems:
306
298
  source:
307
299
  type: git
308
300
  name: ruby/gem_rbs_collection
309
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
301
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
310
302
  remote: https://github.com/ruby/gem_rbs_collection.git
311
303
  repo_dir: gems
312
304
  - name: rbs
313
- version: 3.9.2
305
+ version: 3.9.5
314
306
  source:
315
307
  type: rubygems
316
308
  - name: rdoc
@@ -342,7 +334,7 @@ gems:
342
334
  source:
343
335
  type: git
344
336
  name: ruby/gem_rbs_collection
345
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
337
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
346
338
  remote: https://github.com/ruby/gem_rbs_collection.git
347
339
  repo_dir: gems
348
340
  - name: time
@@ -362,7 +354,7 @@ gems:
362
354
  source:
363
355
  type: git
364
356
  name: ruby/gem_rbs_collection
365
- revision: d2bc0905c6f19acd3023d0530086d6d14704b10f
357
+ revision: ea8449cbfd146213cc46b6e67e747ae61fefed66
366
358
  remote: https://github.com/ruby/gem_rbs_collection.git
367
359
  repo_dir: gems
368
360
  - name: uri
@@ -13,7 +13,7 @@ module RbsRails
13
13
 
14
14
  @enum_definitions: enum_definitions
15
15
 
16
- def enum: (*untyped args, **untyped options) -> void
16
+ def enum: (*untyped args, **untyped options) -> untyped
17
17
 
18
18
  def enum_definitions: () -> Array[[ Symbol, String ]]
19
19
 
@@ -27,6 +27,8 @@ module RbsRails
27
27
 
28
28
  private def klass_decl: () -> String
29
29
 
30
+ private def pk_type_for: (untyped klass) -> String
31
+
30
32
  private def pk_type: () -> String
31
33
 
32
34
  private def generated_relation_methods_decl: () -> String
@@ -49,6 +51,10 @@ module RbsRails
49
51
 
50
52
  private def belongs_to: () -> String
51
53
 
54
+ private def composed_of_aggregations: () -> String
55
+
56
+ private def nested_attributes_methods: () -> String?
57
+
52
58
  private def generated_association_methods: () -> String
53
59
 
54
60
  # @rbs singleton: bool
@@ -15,7 +15,7 @@ module RbsRails
15
15
 
16
16
  @ignore_model_if: (^(singleton(ActiveRecord::Base)) -> bool)?
17
17
 
18
- attr_reader check_db_migrations: bool
18
+ attr_accessor check_db_migrations: bool
19
19
 
20
20
  def initialize: () -> void
21
21
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbs_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masataka Pocke Kuwabara
@@ -106,7 +106,6 @@ files:
106
106
  - sig/rbs_rails/rake_task.rbs
107
107
  - sig/rbs_rails/util.rbs
108
108
  - sig/rbs_rails/util/file_writer.rbs
109
- - sig/rbs_rails/utils/file_writer.rbs
110
109
  - sig/rbs_rails/version.rbs
111
110
  homepage: https://github.com/pocke/rbs_rails
112
111
  licenses:
@@ -129,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
128
  - !ruby/object:Gem::Version
130
129
  version: '0'
131
130
  requirements: []
132
- rubygems_version: 4.0.3
131
+ rubygems_version: 4.0.6
133
132
  specification_version: 4
134
133
  summary: A RBS files generator for Rails application
135
134
  test_files: []
@@ -1,4 +0,0 @@
1
- # Generated from lib/rbs_rails/utils/file_writer.rb with RBS::Inline
2
-
3
- module RbsRails
4
- end