tapioca 0.17.9 → 0.17.10
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/README.md +2 -2
- data/lib/tapioca/commands/abstract_dsl.rb +21 -2
- data/lib/tapioca/commands/abstract_gem.rb +20 -1
- data/lib/tapioca/commands/annotations.rb +7 -1
- data/lib/tapioca/commands/check_shims.rb +9 -1
- data/lib/tapioca/dsl/compiler.rb +17 -12
- data/lib/tapioca/dsl/compilers/aasm.rb +2 -2
- data/lib/tapioca/dsl/compilers/action_controller_helpers.rb +2 -2
- data/lib/tapioca/dsl/compilers/action_mailer.rb +1 -1
- data/lib/tapioca/dsl/compilers/action_text.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_job.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_model_attributes.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_model_secure_password.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_model_validations_confirmation.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_associations.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_columns.rb +8 -2
- data/lib/tapioca/dsl/compilers/active_record_delegated_types.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_enum.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_fixtures.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_relations.rb +12 -81
- data/lib/tapioca/dsl/compilers/active_record_scope.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_secure_token.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_store.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_typed_store.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_resource.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_storage.rb +2 -2
- data/lib/tapioca/dsl/compilers/active_support_concern.rb +6 -6
- data/lib/tapioca/dsl/compilers/active_support_current_attributes.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_support_time_ext.rb +1 -1
- data/lib/tapioca/dsl/compilers/config.rb +2 -2
- data/lib/tapioca/dsl/compilers/frozen_record.rb +1 -1
- data/lib/tapioca/dsl/compilers/graphql_input_object.rb +1 -1
- data/lib/tapioca/dsl/compilers/graphql_mutation.rb +1 -1
- data/lib/tapioca/dsl/compilers/identity_cache.rb +2 -2
- data/lib/tapioca/dsl/compilers/json_api_client_resource.rb +1 -1
- data/lib/tapioca/dsl/compilers/kredis.rb +1 -1
- data/lib/tapioca/dsl/compilers/mixed_in_class_attributes.rb +2 -2
- data/lib/tapioca/dsl/compilers/protobuf.rb +2 -2
- data/lib/tapioca/dsl/compilers/rails_generators.rb +1 -1
- data/lib/tapioca/dsl/compilers/sidekiq_worker.rb +1 -1
- data/lib/tapioca/dsl/compilers/smart_properties.rb +1 -1
- data/lib/tapioca/dsl/compilers/state_machines.rb +2 -2
- data/lib/tapioca/dsl/compilers/url_helpers.rb +7 -7
- data/lib/tapioca/dsl/helpers/active_record_column_type_helper.rb +3 -1
- data/lib/tapioca/dsl/helpers/graphql_type_helper.rb +18 -3
- data/lib/tapioca/dsl/pipeline.rb +25 -11
- data/lib/tapioca/gem/events.rb +15 -8
- data/lib/tapioca/gem/listeners/methods.rb +19 -7
- data/lib/tapioca/gem/listeners/mixins.rb +3 -3
- data/lib/tapioca/gem/listeners/sorbet_type_variables.rb +1 -1
- data/lib/tapioca/gem/pipeline.rb +25 -18
- data/lib/tapioca/gemfile.rb +1 -1
- data/lib/tapioca/helpers/config_helper.rb +5 -1
- data/lib/tapioca/helpers/rbi_files_helper.rb +8 -1
- data/lib/tapioca/loaders/gem.rb +14 -2
- data/lib/tapioca/rbi_ext/model.rb +9 -2
- data/lib/tapioca/repo_index.rb +1 -1
- data/lib/tapioca/runtime/attached_class_of_32.rb +1 -1
- data/lib/tapioca/runtime/attached_class_of_legacy.rb +1 -1
- data/lib/tapioca/runtime/dynamic_mixin_compiler.rb +6 -6
- data/lib/tapioca/runtime/generic_type_registry.rb +8 -8
- data/lib/tapioca/runtime/reflection.rb +19 -19
- data/lib/tapioca/runtime/trackers/constant_definition.rb +3 -3
- data/lib/tapioca/runtime/trackers/method_definition.rb +4 -4
- data/lib/tapioca/runtime/trackers/mixin.rb +5 -5
- data/lib/tapioca/runtime/trackers/required_ancestor.rb +2 -2
- data/lib/tapioca/runtime/trackers/tracker.rb +1 -1
- data/lib/tapioca/sorbet_ext/generic_name_patch.rb +1 -1
- data/lib/tapioca/static/requires_compiler.rb +1 -1
- data/lib/tapioca/version.rb +1 -1
- 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: fd0aedb9a8295fc96a30b43e9a3da1f84bebdf3f97bb2fbd1fd99375fdad6fc1
|
|
4
|
+
data.tar.gz: 2c649b047df9cb012f7ed8502c9206e419e70a6bc7c1d2d07785aaad51af649e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d1fe2a59d4570b065179f64d6de4e6bd27f494b2c23545c4a2ccf64a9cf33383ca5fd99a5eaf1ac3d93ff720b68780504b09beb501ad5567c6ea5c917d9004fe
|
|
7
|
+
data.tar.gz: '08514a0edef06b920cc2a07493f86f9a428e33554d1509210cfc4a0d044735303043efceb1a14f3ce2d18b29d4693bcd8e36a9153c4c4c836aa0fcbacd5110ef'
|
data/README.md
CHANGED
|
@@ -673,7 +673,7 @@ module Tapioca
|
|
|
673
673
|
|
|
674
674
|
ConstantType = type_member {{ fixed: T.class_of(Encryptable) }}
|
|
675
675
|
|
|
676
|
-
sig { override.returns(T::Enumerable[Module]) }
|
|
676
|
+
sig { override.returns(T::Enumerable[T::Module[T.anything]]) }
|
|
677
677
|
def self.gather_constants
|
|
678
678
|
# Collect all the classes that include Encryptable
|
|
679
679
|
all_classes.select { |c| c < ::Encryptable }
|
|
@@ -806,7 +806,7 @@ module Tapioca
|
|
|
806
806
|
|
|
807
807
|
ConstantType = type_member {{ fixed: T.class_of(Encryptable) }}
|
|
808
808
|
|
|
809
|
-
sig { override.returns(T::Enumerable[Module]) }
|
|
809
|
+
sig { override.returns(T::Enumerable[T::Module[T.anything]]) }
|
|
810
810
|
def self.gather_constants
|
|
811
811
|
# Collect all the classes that include Encryptable
|
|
812
812
|
all_classes.select { |c| c < ::Encryptable }
|
|
@@ -8,7 +8,26 @@ module Tapioca
|
|
|
8
8
|
include SorbetHelper
|
|
9
9
|
include RBIFilesHelper
|
|
10
10
|
|
|
11
|
-
#: (
|
|
11
|
+
#: (
|
|
12
|
+
#| requested_constants: Array[String],
|
|
13
|
+
#| requested_paths: Array[Pathname],
|
|
14
|
+
#| outpath: Pathname,
|
|
15
|
+
#| only: Array[String],
|
|
16
|
+
#| exclude: Array[String],
|
|
17
|
+
#| file_header: bool,
|
|
18
|
+
#| tapioca_path: String,
|
|
19
|
+
#| ?skip_constant: Array[String],
|
|
20
|
+
#| ?quiet: bool,
|
|
21
|
+
#| ?verbose: bool,
|
|
22
|
+
#| ?number_of_workers: Integer?,
|
|
23
|
+
#| ?auto_strictness: bool,
|
|
24
|
+
#| ?gem_dir: String,
|
|
25
|
+
#| ?rbi_formatter: RBIFormatter,
|
|
26
|
+
#| ?app_root: String,
|
|
27
|
+
#| ?halt_upon_load_error: bool,
|
|
28
|
+
#| ?compiler_options: Hash[String, untyped],
|
|
29
|
+
#| ?lsp_addon: bool
|
|
30
|
+
#| ) -> void
|
|
12
31
|
def initialize(
|
|
13
32
|
requested_constants:,
|
|
14
33
|
requested_paths:,
|
|
@@ -143,7 +162,7 @@ module Tapioca
|
|
|
143
162
|
filenames.to_set
|
|
144
163
|
end
|
|
145
164
|
|
|
146
|
-
#: (Array[String] constant_names, ?ignore_missing: bool) -> Array[Module]
|
|
165
|
+
#: (Array[String] constant_names, ?ignore_missing: bool) -> Array[T::Module[top]]
|
|
147
166
|
def constantize(constant_names, ignore_missing: false)
|
|
148
167
|
constant_map = constant_names.to_h do |name|
|
|
149
168
|
[name, Object.const_get(name)]
|
|
@@ -8,7 +8,26 @@ module Tapioca
|
|
|
8
8
|
include SorbetHelper
|
|
9
9
|
include RBIFilesHelper
|
|
10
10
|
|
|
11
|
-
#: (
|
|
11
|
+
#: (
|
|
12
|
+
#| gem_names: Array[String],
|
|
13
|
+
#| exclude: Array[String],
|
|
14
|
+
#| include_dependencies: bool,
|
|
15
|
+
#| prerequire: String?,
|
|
16
|
+
#| postrequire: String,
|
|
17
|
+
#| typed_overrides: Hash[String, String],
|
|
18
|
+
#| outpath: Pathname,
|
|
19
|
+
#| file_header: bool,
|
|
20
|
+
#| include_doc: bool,
|
|
21
|
+
#| include_loc: bool,
|
|
22
|
+
#| include_exported_rbis: bool,
|
|
23
|
+
#| ?number_of_workers: Integer?,
|
|
24
|
+
#| ?auto_strictness: bool,
|
|
25
|
+
#| ?dsl_dir: String,
|
|
26
|
+
#| ?rbi_formatter: RBIFormatter,
|
|
27
|
+
#| ?halt_upon_load_error: bool,
|
|
28
|
+
#| ?lsp_addon: bool?,
|
|
29
|
+
#| ?verbose: bool?
|
|
30
|
+
#| ) -> void
|
|
12
31
|
def initialize(
|
|
13
32
|
gem_names:,
|
|
14
33
|
exclude:,
|
|
@@ -6,7 +6,13 @@ module Tapioca
|
|
|
6
6
|
class Annotations < CommandWithoutTracker
|
|
7
7
|
extend T::Sig
|
|
8
8
|
|
|
9
|
-
#: (
|
|
9
|
+
#: (
|
|
10
|
+
#| central_repo_root_uris: Array[String],
|
|
11
|
+
#| ?auth: String?,
|
|
12
|
+
#| ?netrc_file: String?,
|
|
13
|
+
#| ?central_repo_index_path: String,
|
|
14
|
+
#| ?typed_overrides: Hash[String, String]
|
|
15
|
+
#| ) -> void
|
|
10
16
|
def initialize(
|
|
11
17
|
central_repo_root_uris:,
|
|
12
18
|
auth: nil,
|
|
@@ -8,7 +8,15 @@ module Tapioca
|
|
|
8
8
|
include SorbetHelper
|
|
9
9
|
include RBIFilesHelper
|
|
10
10
|
|
|
11
|
-
#: (
|
|
11
|
+
#: (
|
|
12
|
+
#| gem_rbi_dir: String,
|
|
13
|
+
#| dsl_rbi_dir: String,
|
|
14
|
+
#| annotations_rbi_dir: String,
|
|
15
|
+
#| shim_rbi_dir: String,
|
|
16
|
+
#| todo_rbi_file: String,
|
|
17
|
+
#| payload: bool,
|
|
18
|
+
#| number_of_workers: Integer?
|
|
19
|
+
#| ) -> void
|
|
12
20
|
def initialize(
|
|
13
21
|
gem_rbi_dir:,
|
|
14
22
|
dsl_rbi_dir:,
|
data/lib/tapioca/dsl/compiler.rb
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
module Tapioca
|
|
5
5
|
module Dsl
|
|
6
6
|
# @abstract
|
|
7
|
-
#: [ConstantType < Module]
|
|
7
|
+
#: [ConstantType < T::Module[top]]
|
|
8
8
|
class Compiler
|
|
9
9
|
extend T::Sig
|
|
10
10
|
|
|
@@ -21,26 +21,26 @@ module Tapioca
|
|
|
21
21
|
#: Hash[String, untyped]
|
|
22
22
|
attr_reader :options
|
|
23
23
|
|
|
24
|
-
@@requested_constants = [] #: Array[Module] # rubocop:disable Style/ClassVars
|
|
24
|
+
@@requested_constants = [] #: Array[T::Module[top]] # rubocop:disable Style/ClassVars
|
|
25
25
|
|
|
26
26
|
class << self
|
|
27
27
|
extend T::Sig
|
|
28
28
|
|
|
29
|
-
#: (Module constant) -> bool
|
|
29
|
+
#: (T::Module[top] constant) -> bool
|
|
30
30
|
def handles?(constant)
|
|
31
31
|
processable_constants.include?(constant)
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
# @abstract
|
|
35
|
-
#: -> T::
|
|
35
|
+
#: -> Enumerable[T::Module[top]]
|
|
36
36
|
def gather_constants = raise NotImplementedError, "Abstract method called"
|
|
37
37
|
|
|
38
|
-
#: -> Set[Module]
|
|
38
|
+
#: -> Set[T::Module[top]]
|
|
39
39
|
def processable_constants
|
|
40
|
-
@processable_constants ||= T::Set[Module].new.compare_by_identity.merge(gather_constants) #: Set[Module]?
|
|
40
|
+
@processable_constants ||= T::Set[T::Module[T.anything]].new.compare_by_identity.merge(gather_constants) #: Set[T::Module[top]]?
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
-
#: (Array[Module] constants) -> void
|
|
43
|
+
#: (Array[T::Module[top]] constants) -> void
|
|
44
44
|
def requested_constants=(constants)
|
|
45
45
|
@@requested_constants = constants # rubocop:disable Style/ClassVars
|
|
46
46
|
end
|
|
@@ -68,22 +68,27 @@ module Tapioca
|
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
-
#: ->
|
|
71
|
+
#: -> Enumerable[Class[top]]
|
|
72
72
|
def all_classes
|
|
73
|
-
@all_classes ||= all_modules.grep(Class).freeze #:
|
|
73
|
+
@all_classes ||= all_modules.grep(Class).freeze #: Enumerable[Class[top]]?
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
-
#: -> T::
|
|
76
|
+
#: -> Enumerable[T::Module[top]]
|
|
77
77
|
def all_modules
|
|
78
78
|
@all_modules ||= if @@requested_constants.any?
|
|
79
79
|
@@requested_constants.grep(Module)
|
|
80
80
|
else
|
|
81
81
|
ObjectSpace.each_object(Module).to_a
|
|
82
|
-
end.freeze #: T::
|
|
82
|
+
end.freeze #: Enumerable[T::Module[top]]?
|
|
83
83
|
end
|
|
84
84
|
end
|
|
85
85
|
|
|
86
|
-
#: (
|
|
86
|
+
#: (
|
|
87
|
+
#| Tapioca::Dsl::Pipeline pipeline,
|
|
88
|
+
#| RBI::Tree root,
|
|
89
|
+
#| ConstantType constant,
|
|
90
|
+
#| ?Hash[String, untyped] options
|
|
91
|
+
#| ) -> void
|
|
87
92
|
def initialize(pipeline, root, constant, options = {})
|
|
88
93
|
@pipeline = pipeline
|
|
89
94
|
@root = root
|
|
@@ -203,9 +203,9 @@ module Tapioca
|
|
|
203
203
|
extend T::Sig
|
|
204
204
|
|
|
205
205
|
# @override
|
|
206
|
-
#: -> T::
|
|
206
|
+
#: -> Enumerable[T::Module[top]]
|
|
207
207
|
def gather_constants
|
|
208
|
-
T.cast(ObjectSpace.each_object(::AASM::ClassMethods), T::Enumerable[Module])
|
|
208
|
+
T.cast(ObjectSpace.each_object(::AASM::ClassMethods), T::Enumerable[T::Module[T.anything]])
|
|
209
209
|
end
|
|
210
210
|
end
|
|
211
211
|
end
|
|
@@ -121,7 +121,7 @@ module Tapioca
|
|
|
121
121
|
extend T::Sig
|
|
122
122
|
|
|
123
123
|
# @override
|
|
124
|
-
#: -> T::
|
|
124
|
+
#: -> Enumerable[T::Module[top]]
|
|
125
125
|
def gather_constants
|
|
126
126
|
descendants_of(::ActionController::Base).select(&:name).select do |klass|
|
|
127
127
|
klass.const_defined?(:HelperMethods, false)
|
|
@@ -152,7 +152,7 @@ module Tapioca
|
|
|
152
152
|
)
|
|
153
153
|
end
|
|
154
154
|
|
|
155
|
-
#: (Module mod) -> Array[String]
|
|
155
|
+
#: (T::Module[top] mod) -> Array[String]
|
|
156
156
|
def gather_includes(mod)
|
|
157
157
|
mod.ancestors
|
|
158
158
|
.reject { |ancestor| ancestor.is_a?(Class) || ancestor == mod || name_of(ancestor).nil? }
|
|
@@ -93,7 +93,7 @@ module Tapioca
|
|
|
93
93
|
extend T::Sig
|
|
94
94
|
|
|
95
95
|
# @override
|
|
96
|
-
#: -> T::
|
|
96
|
+
#: -> Enumerable[T::Module[top]]
|
|
97
97
|
def gather_constants
|
|
98
98
|
# In some versions of Rails 8.1, `ActiveModel::SecurePassword` uses `Numeric#minutes`
|
|
99
99
|
# which isn't explicitly required in the gem, and it might not be loaded already.
|
|
@@ -46,7 +46,7 @@ module Tapioca
|
|
|
46
46
|
|
|
47
47
|
class << self
|
|
48
48
|
# @override
|
|
49
|
-
#: -> T::
|
|
49
|
+
#: -> Enumerable[T::Module[top]]
|
|
50
50
|
def gather_constants
|
|
51
51
|
# Collect all the classes that include ActiveModel::Validations
|
|
52
52
|
all_classes.select { |c| ActiveModel::Validations > c }
|
|
@@ -166,7 +166,7 @@ module Tapioca
|
|
|
166
166
|
extend T::Sig
|
|
167
167
|
|
|
168
168
|
# @override
|
|
169
|
-
#: -> T::
|
|
169
|
+
#: -> Enumerable[T::Module[top]]
|
|
170
170
|
def gather_constants
|
|
171
171
|
descendants_of(::ActiveRecord::Base).reject(&:abstract_class?)
|
|
172
172
|
end
|
|
@@ -189,7 +189,13 @@ module Tapioca
|
|
|
189
189
|
)
|
|
190
190
|
end
|
|
191
191
|
|
|
192
|
-
#: (
|
|
192
|
+
#: (
|
|
193
|
+
#| RBI::Scope klass,
|
|
194
|
+
#| String name,
|
|
195
|
+
#| Array[String]? methods_to_add,
|
|
196
|
+
#| ?return_type: String,
|
|
197
|
+
#| ?parameters: Array[RBI::TypedParam]
|
|
198
|
+
#| ) -> void
|
|
193
199
|
def add_method(klass, name, methods_to_add, return_type: "void", parameters: [])
|
|
194
200
|
klass.create_method(
|
|
195
201
|
name,
|
|
@@ -184,7 +184,7 @@ module Tapioca
|
|
|
184
184
|
extend T::Sig
|
|
185
185
|
|
|
186
186
|
# @override
|
|
187
|
-
#: -> T::
|
|
187
|
+
#: -> Enumerable[T::Module[top]]
|
|
188
188
|
def gather_constants
|
|
189
189
|
ActiveRecord::Base.descendants.reject(&:abstract_class?)
|
|
190
190
|
end
|
|
@@ -604,47 +604,9 @@ module Tapioca
|
|
|
604
604
|
|
|
605
605
|
#: -> void
|
|
606
606
|
def create_association_relation_methods
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
ASSOCIATION_METHODS.each do |method_name|
|
|
611
|
-
case method_name
|
|
612
|
-
when :insert_all, :insert_all!, :upsert_all
|
|
613
|
-
parameters = [
|
|
614
|
-
create_param("attributes", type: "T::Array[Hash]"),
|
|
615
|
-
create_kw_opt_param("returning", type: returning_type, default: "nil"),
|
|
616
|
-
]
|
|
617
|
-
|
|
618
|
-
# Bang methods don't have the `unique_by` parameter
|
|
619
|
-
unless bang_method?(method_name)
|
|
620
|
-
parameters << create_kw_opt_param("unique_by", type: unique_by_type, default: "nil")
|
|
621
|
-
end
|
|
622
|
-
|
|
623
|
-
association_relation_methods_module.create_method(
|
|
624
|
-
method_name.to_s,
|
|
625
|
-
parameters: parameters,
|
|
626
|
-
return_type: "ActiveRecord::Result",
|
|
627
|
-
)
|
|
628
|
-
when :insert, :insert!, :upsert
|
|
629
|
-
parameters = [
|
|
630
|
-
create_param("attributes", type: "Hash"),
|
|
631
|
-
create_kw_opt_param("returning", type: returning_type, default: "nil"),
|
|
632
|
-
]
|
|
633
|
-
|
|
634
|
-
# Bang methods don't have the `unique_by` parameter
|
|
635
|
-
unless bang_method?(method_name)
|
|
636
|
-
parameters << create_kw_opt_param("unique_by", type: unique_by_type, default: "nil")
|
|
637
|
-
end
|
|
638
|
-
|
|
639
|
-
association_relation_methods_module.create_method(
|
|
640
|
-
method_name.to_s,
|
|
641
|
-
parameters: parameters,
|
|
642
|
-
return_type: "ActiveRecord::Result",
|
|
643
|
-
)
|
|
644
|
-
when :proxy_association
|
|
645
|
-
# skip - private method
|
|
646
|
-
end
|
|
647
|
-
end
|
|
607
|
+
# skips insert/upsert methods - these methods' signatures aren't model-specific and don't need to be generated dynamically
|
|
608
|
+
# also skips proxy_association method - it's a private method
|
|
609
|
+
# but there could be other association methods that we need to generate
|
|
648
610
|
end
|
|
649
611
|
|
|
650
612
|
#: -> void
|
|
@@ -953,44 +915,8 @@ module Tapioca
|
|
|
953
915
|
sig.return_type = constant_name
|
|
954
916
|
end
|
|
955
917
|
end
|
|
956
|
-
when :insert_all, :insert_all!, :upsert_all # insert
|
|
957
|
-
|
|
958
|
-
unique_by_type = "T.nilable(T.any(T::Array[Symbol], Symbol))"
|
|
959
|
-
|
|
960
|
-
parameters = [
|
|
961
|
-
create_param("attributes", type: "T::Array[Hash]"),
|
|
962
|
-
create_kw_opt_param("returning", type: returning_type, default: "nil"),
|
|
963
|
-
]
|
|
964
|
-
|
|
965
|
-
# Bang methods don't have the `unique_by` parameter
|
|
966
|
-
unless bang_method?(method_name)
|
|
967
|
-
parameters << create_kw_opt_param("unique_by", type: unique_by_type, default: "nil")
|
|
968
|
-
end
|
|
969
|
-
|
|
970
|
-
common_relation_methods_module.create_method(
|
|
971
|
-
method_name.to_s,
|
|
972
|
-
parameters: parameters,
|
|
973
|
-
return_type: "ActiveRecord::Result",
|
|
974
|
-
)
|
|
975
|
-
when :insert, :insert!, :upsert # insert methods
|
|
976
|
-
returning_type = "T.nilable(T.any(T::Array[Symbol], FalseClass))"
|
|
977
|
-
unique_by_type = "T.nilable(T.any(T::Array[Symbol], Symbol))"
|
|
978
|
-
|
|
979
|
-
parameters = [
|
|
980
|
-
create_param("attributes", type: "Hash"),
|
|
981
|
-
create_kw_opt_param("returning", type: returning_type, default: "nil"),
|
|
982
|
-
]
|
|
983
|
-
|
|
984
|
-
# Bang methods don't have the `unique_by` parameter
|
|
985
|
-
unless bang_method?(method_name)
|
|
986
|
-
parameters << create_kw_opt_param("unique_by", type: unique_by_type, default: "nil")
|
|
987
|
-
end
|
|
988
|
-
|
|
989
|
-
common_relation_methods_module.create_method(
|
|
990
|
-
method_name.to_s,
|
|
991
|
-
parameters: parameters,
|
|
992
|
-
return_type: "ActiveRecord::Result",
|
|
993
|
-
)
|
|
918
|
+
when :insert_all, :insert_all!, :upsert_all, :insert, :insert!, :upsert # insert methods
|
|
919
|
+
# skip - these methods' signatures aren't model-specific and don't need to be generated dynamically
|
|
994
920
|
when :delete, :destroy
|
|
995
921
|
# For these cases, it is valid to pass the above kind of things, but also:
|
|
996
922
|
# - a model identifier, which can be:
|
|
@@ -1107,7 +1033,12 @@ module Tapioca
|
|
|
1107
1033
|
end
|
|
1108
1034
|
end
|
|
1109
1035
|
|
|
1110
|
-
#: (
|
|
1036
|
+
#: (
|
|
1037
|
+
#| (Symbol | String) name,
|
|
1038
|
+
#| ?parameters: Array[RBI::TypedParam],
|
|
1039
|
+
#| ?relation_return_type: String,
|
|
1040
|
+
#| ?association_return_type: String
|
|
1041
|
+
#| ) -> void
|
|
1111
1042
|
def create_relation_method(
|
|
1112
1043
|
name,
|
|
1113
1044
|
parameters: [],
|
|
@@ -111,7 +111,7 @@ module Tapioca
|
|
|
111
111
|
extend T::Sig
|
|
112
112
|
|
|
113
113
|
# @override
|
|
114
|
-
#: -> T::
|
|
114
|
+
#: -> Enumerable[T::Module[top]]
|
|
115
115
|
def gather_constants
|
|
116
116
|
descendants_of(::ActiveRecord::Base).select do |klass|
|
|
117
117
|
klass.include?(ActiveRecord::TypedStore::Behavior)
|
|
@@ -38,7 +38,7 @@ module Tapioca
|
|
|
38
38
|
# def photo=(attachable); end
|
|
39
39
|
# end
|
|
40
40
|
# ~~~
|
|
41
|
-
#: [ConstantType = (Module & ::ActiveStorage::Reflection::ActiveRecordExtensions::ClassMethods)]
|
|
41
|
+
#: [ConstantType = (T::Module[top] & ::ActiveStorage::Reflection::ActiveRecordExtensions::ClassMethods)]
|
|
42
42
|
class ActiveStorage < Compiler
|
|
43
43
|
extend T::Sig
|
|
44
44
|
|
|
@@ -68,7 +68,7 @@ module Tapioca
|
|
|
68
68
|
extend T::Sig
|
|
69
69
|
|
|
70
70
|
# @override
|
|
71
|
-
#: -> T::
|
|
71
|
+
#: -> Enumerable[T::Module[top]]
|
|
72
72
|
def gather_constants
|
|
73
73
|
descendants_of(::ActiveRecord::Base)
|
|
74
74
|
.reject(&:abstract_class?)
|
|
@@ -37,7 +37,7 @@ module Tapioca
|
|
|
37
37
|
# mixes_in_class_methods(::Foo::ClassMethods)
|
|
38
38
|
# end
|
|
39
39
|
# ~~~
|
|
40
|
-
#: [ConstantType = Module]
|
|
40
|
+
#: [ConstantType = T::Module[top]]
|
|
41
41
|
class ActiveSupportConcern < Compiler
|
|
42
42
|
extend T::Sig
|
|
43
43
|
|
|
@@ -65,7 +65,7 @@ module Tapioca
|
|
|
65
65
|
extend T::Sig
|
|
66
66
|
|
|
67
67
|
# @override
|
|
68
|
-
#: -> T::
|
|
68
|
+
#: -> Enumerable[T::Module[top]]
|
|
69
69
|
def gather_constants
|
|
70
70
|
all_modules.select do |mod|
|
|
71
71
|
name_of(mod) && # i.e. not anonymous
|
|
@@ -76,10 +76,10 @@ module Tapioca
|
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
# Returns true when `mod` includes other concerns
|
|
79
|
-
#: (Module mod) -> bool
|
|
79
|
+
#: (T::Module[top] mod) -> bool
|
|
80
80
|
def has_dependencies?(mod) = dependencies_of(mod).any?
|
|
81
81
|
|
|
82
|
-
#: (Module concern) -> Array[Module]
|
|
82
|
+
#: (T::Module[top] concern) -> Array[T::Module[top]]
|
|
83
83
|
def dependencies_of(concern)
|
|
84
84
|
concern.instance_variable_get(:@_dependencies) || []
|
|
85
85
|
end
|
|
@@ -87,12 +87,12 @@ module Tapioca
|
|
|
87
87
|
|
|
88
88
|
private
|
|
89
89
|
|
|
90
|
-
#: (Module concern) -> Array[Module]
|
|
90
|
+
#: (T::Module[top] concern) -> Array[T::Module[top]]
|
|
91
91
|
def dependencies_of(concern)
|
|
92
92
|
self.class.dependencies_of(concern)
|
|
93
93
|
end
|
|
94
94
|
|
|
95
|
-
#: (?Module concern) -> Array[Module]
|
|
95
|
+
#: (?T::Module[top] concern) -> Array[T::Module[top]]
|
|
96
96
|
def linearized_dependencies(concern = constant)
|
|
97
97
|
# Grab all the dependencies of the concern
|
|
98
98
|
dependencies = dependencies_of(concern)
|
|
@@ -40,7 +40,7 @@ module Tapioca
|
|
|
40
40
|
# def github=(value); end
|
|
41
41
|
# end
|
|
42
42
|
# ```
|
|
43
|
-
#: [ConstantType = Module]
|
|
43
|
+
#: [ConstantType = T::Module[top]]
|
|
44
44
|
class Config < Compiler
|
|
45
45
|
extend T::Sig
|
|
46
46
|
|
|
@@ -96,7 +96,7 @@ module Tapioca
|
|
|
96
96
|
extend T::Sig
|
|
97
97
|
|
|
98
98
|
# @override
|
|
99
|
-
#: -> T::
|
|
99
|
+
#: -> Enumerable[T::Module[top]]
|
|
100
100
|
def gather_constants
|
|
101
101
|
name = ::Config.const_name
|
|
102
102
|
return [] unless Object.const_defined?(name)
|