sorbet-rails 0.7.27 → 0.7.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci-master.yml +2 -0
- data/README.md +1 -0
- data/lib/sorbet-rails/gem_plugins/aasm_plugin.rb +7 -2
- data/lib/sorbet-rails/model_column_utils.rb +1 -1
- data/lib/sorbet-rails/model_plugins/active_record_assoc.rb +1 -1
- data/spec/sorbet_spec.rb +3 -0
- data/spec/test_data/v5.2/expected_wizard_wo_spellbook.rbi +3 -3
- data/spec/test_data/v6.0/expected_wizard_wo_spellbook.rbi +3 -3
- data/spec/test_data/v6.1/expected_wizard_wo_spellbook.rbi +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c8486bf0c5537443c859e1f51c4aebd3e62bd16370f78526a4f2e879b148c81
|
4
|
+
data.tar.gz: ffd9da9622e74e186ae94eb9547da174df0e86e294373b06bbdf4caf4d71736f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9b9d08940d9c0c82984326439fd8c310955e6c3c59a1b6ed01c46c5ab05ca71680e9627f0bef456942ad2c08430d216ad969a0506c2478c0fec5863a3bb3d32
|
7
|
+
data.tar.gz: 82f9e89b908de82b1a63f02f60cef7aea5ded0108c2717b3e3aa1ee0ac2ee534476327fb5483a155d98d95f9f35640534ce133a2b017daf31797844725a91138
|
data/README.md
CHANGED
@@ -365,6 +365,7 @@ Following are the list of attribute dynamic methods and their static counterpart
|
|
365
365
|
- `<attribute>_was` -> `attribute_was(<attribute>)`
|
366
366
|
- `saved_change_to_<attribute>?` -> `saved_change_to_attribute?(<attribute>)`
|
367
367
|
- `<attribute>_before_type_cast` -> `read_attribute_before_type_cast(<attribute>)`
|
368
|
+
- `will_save_change_to_<attribute>?` -> `will_save_change_to_attribute?(<attribute>)`
|
368
369
|
|
369
370
|
### `after_commit` and other callbacks
|
370
371
|
|
@@ -38,13 +38,18 @@ class AasmPlugin < SorbetRails::ModelPlugins::Base
|
|
38
38
|
)
|
39
39
|
end
|
40
40
|
|
41
|
-
# - If you have a state like :baz, you get
|
42
|
-
# - `baz?`
|
41
|
+
# - If you have a state like :baz, you get:
|
42
|
+
# - a method `baz?`
|
43
|
+
# - a constant `STATE_BAZ`
|
43
44
|
aasm_states.each do |state|
|
44
45
|
model_rbi.create_method(
|
45
46
|
"#{state}?",
|
46
47
|
return_type: 'T::Boolean'
|
47
48
|
)
|
49
|
+
|
50
|
+
root.create_module(
|
51
|
+
"#{model_class_name}::STATE_#{state.to_s.upcase}"
|
52
|
+
)
|
48
53
|
end
|
49
54
|
end
|
50
55
|
end
|
@@ -17,7 +17,7 @@ module SorbetRails::ModelColumnUtils
|
|
17
17
|
type = base_type.to_s
|
18
18
|
# A nullable array column should be T.nilable(T::Array[column_type]) not T::Array[T.nilable(column_type)]
|
19
19
|
type = "T::Array[#{type}]" if array_type
|
20
|
-
type = "T.nilable(#{type})" if nilable
|
20
|
+
type = "T.nilable(#{type})" if nilable && type != "T.untyped"
|
21
21
|
type
|
22
22
|
end
|
23
23
|
end
|
@@ -34,7 +34,7 @@ class SorbetRails::ModelPlugins::ActiveRecordAssoc < SorbetRails::ModelPlugins::
|
|
34
34
|
def populate_single_assoc_getter_setter(assoc_module_rbi, assoc_name, reflection)
|
35
35
|
# TODO allow people to specify the possible values of polymorphic associations
|
36
36
|
assoc_class = assoc_should_be_untyped?(reflection) ? "T.untyped" : "::#{reflection.klass.name}"
|
37
|
-
assoc_type = (belongs_to_and_required?(reflection) || has_one_and_required?(reflection)) ? assoc_class : "T.nilable(#{assoc_class})"
|
37
|
+
assoc_type = (belongs_to_and_required?(reflection) || has_one_and_required?(reflection) || assoc_class == "T.untyped") ? assoc_class : "T.nilable(#{assoc_class})"
|
38
38
|
|
39
39
|
params = [
|
40
40
|
Parameter.new("*args", type: "T.untyped"),
|
data/spec/sorbet_spec.rb
CHANGED
@@ -63,6 +63,9 @@ RSpec.describe 'sorbet' do
|
|
63
63
|
# run sorbet-rails rake tasks
|
64
64
|
Rake::Task['rails_rbi:all'].invoke
|
65
65
|
|
66
|
+
# ensure we remove sorbet-rails.rbi as there are conflicts which cause srb tc to fail
|
67
|
+
FileUtils.rm_f(Rails.root.join('sorbet/rbi/gems/sorbet-rails.rbi'))
|
68
|
+
|
66
69
|
# Regenerate hidden-definitions because there might be conflicts between signature
|
67
70
|
# generated by sorbet-rails & by hidden-definitions
|
68
71
|
# They should be resolved when re-running this script
|
@@ -287,7 +287,7 @@ module Wizard::GeneratedAssociationMethods
|
|
287
287
|
sig { params(value: T::Enumerable[::ActiveStorage::Blob]).void }
|
288
288
|
def hats_blobs=(value); end
|
289
289
|
|
290
|
-
sig { returns(T.
|
290
|
+
sig { returns(T.untyped) }
|
291
291
|
def school; end
|
292
292
|
|
293
293
|
sig { params(args: T.untyped, block: T.nilable(T.proc.params(object: T.untyped).void)).returns(T.untyped) }
|
@@ -299,10 +299,10 @@ module Wizard::GeneratedAssociationMethods
|
|
299
299
|
sig { params(args: T.untyped, block: T.nilable(T.proc.params(object: T.untyped).void)).returns(T.untyped) }
|
300
300
|
def create_school!(*args, &block); end
|
301
301
|
|
302
|
-
sig { params(value: T.
|
302
|
+
sig { params(value: T.untyped).void }
|
303
303
|
def school=(value); end
|
304
304
|
|
305
|
-
sig { returns(T.
|
305
|
+
sig { returns(T.untyped) }
|
306
306
|
def reload_school; end
|
307
307
|
|
308
308
|
sig { returns(T.nilable(::ActiveStorage::Attachment)) }
|
@@ -1134,7 +1134,7 @@ module Wizard::GeneratedAssociationMethods
|
|
1134
1134
|
sig { params(value: T::Enumerable[::ActiveStorage::Blob]).void }
|
1135
1135
|
def hats_blobs=(value); end
|
1136
1136
|
|
1137
|
-
sig { returns(T.
|
1137
|
+
sig { returns(T.untyped) }
|
1138
1138
|
def school; end
|
1139
1139
|
|
1140
1140
|
sig { params(args: T.untyped, block: T.nilable(T.proc.params(object: T.untyped).void)).returns(T.untyped) }
|
@@ -1146,10 +1146,10 @@ module Wizard::GeneratedAssociationMethods
|
|
1146
1146
|
sig { params(args: T.untyped, block: T.nilable(T.proc.params(object: T.untyped).void)).returns(T.untyped) }
|
1147
1147
|
def create_school!(*args, &block); end
|
1148
1148
|
|
1149
|
-
sig { params(value: T.
|
1149
|
+
sig { params(value: T.untyped).void }
|
1150
1150
|
def school=(value); end
|
1151
1151
|
|
1152
|
-
sig { returns(T.
|
1152
|
+
sig { returns(T.untyped) }
|
1153
1153
|
def reload_school; end
|
1154
1154
|
|
1155
1155
|
sig { returns(T.nilable(::ActiveStorage::Attachment)) }
|
@@ -1254,7 +1254,7 @@ module Wizard::GeneratedAssociationMethods
|
|
1254
1254
|
sig { params(value: T::Enumerable[::ActiveStorage::Blob]).void }
|
1255
1255
|
def hats_blobs=(value); end
|
1256
1256
|
|
1257
|
-
sig { returns(T.
|
1257
|
+
sig { returns(T.untyped) }
|
1258
1258
|
def school; end
|
1259
1259
|
|
1260
1260
|
sig { params(args: T.untyped, block: T.nilable(T.proc.params(object: T.untyped).void)).returns(T.untyped) }
|
@@ -1266,10 +1266,10 @@ module Wizard::GeneratedAssociationMethods
|
|
1266
1266
|
sig { params(args: T.untyped, block: T.nilable(T.proc.params(object: T.untyped).void)).returns(T.untyped) }
|
1267
1267
|
def create_school!(*args, &block); end
|
1268
1268
|
|
1269
|
-
sig { params(value: T.
|
1269
|
+
sig { params(value: T.untyped).void }
|
1270
1270
|
def school=(value); end
|
1271
1271
|
|
1272
|
-
sig { returns(T.
|
1272
|
+
sig { returns(T.untyped) }
|
1273
1273
|
def reload_school; end
|
1274
1274
|
|
1275
1275
|
sig { returns(T.nilable(::ActiveStorage::Attachment)) }
|