rails-on-sorbet 0.2.8 → 0.3.0
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/CHANGELOG.md +7 -0
- data/README.md +62 -6
- data/lib/rails/on/sorbet/typed_relation.rb +58 -0
- data/lib/rails/on/sorbet/version.rb +1 -1
- data/lib/tapioca/dsl/compilers/rails_on_sorbet_active_record.rb +49 -0
- data/rbi/typed_relation.rbi +944 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe4169663fb8997f73abd67b1c4194a1f74ec2feacd2d852e1591e6de8c10edc
|
4
|
+
data.tar.gz: b2e5dbb4522948405d21ab34fb0bb6ed5efdbe1ca75f58098a190030b8de3615
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0591ea92aef3fa4fd12eec00ad5f8fd8239b7caf94619bf80d0f0fe69568fa23a99eab69b2ab5c049efa1dc178021c3ee88acc0a2b877bdf03d50d0fa9f0f3d
|
7
|
+
data.tar.gz: eea1bbe85c46586953ab218ef0398d122568109f0c8d67a710d348323f696d753e8360b8d48ac97175907294010e1ff9145f13e0667da8eb586cef7a44df2b06
|
data/CHANGELOG.md
CHANGED
@@ -12,6 +12,13 @@ Add changes in new features here. Do not change the gem's version in pull/merge
|
|
12
12
|
### Changes
|
13
13
|
-
|
14
14
|
|
15
|
+
## [0.3.0] - 20.10.2025
|
16
|
+
|
17
|
+
[Diff](https://github.com/espago/rails-on-sorbet/compare/v0.2.8...v0.3.0)
|
18
|
+
|
19
|
+
### Changes
|
20
|
+
- Add `TypedRelation` and `TypedAssociation` for better ActiveRecord::Relation sorbet handling
|
21
|
+
|
15
22
|
## [0.2.8] - 16.10.2025
|
16
23
|
|
17
24
|
[Diff](https://github.com/espago/rails-on-sorbet/compare/v0.2.7...v0.2.8)
|
data/README.md
CHANGED
@@ -85,6 +85,62 @@ m = Map(params) #=> Map[String, untyped]
|
|
85
85
|
foo(m) # OK
|
86
86
|
```
|
87
87
|
|
88
|
+
### TypedRelation
|
89
|
+
|
90
|
+
Sorbet lacks proper generic handling of `ActiveRecord::Relation`.
|
91
|
+
The class itself is not generic and tapioca generates a bunch of classes like `X::PrivateRelation`, `X::PrivateAssociationRelation`, `X::PrivateCollectionProxy` per model but these classes have no common generic ancestors which makes them incredibly finnicky to work with.
|
92
|
+
|
93
|
+
Because of that we introduced a bunch of interfaces:
|
94
|
+
- `TypedRelation` is included by per-model classes like `X::PrivateRelation`
|
95
|
+
- `TypedAssociation::Relation` is included by per-model classes like `X::PrivateAssociationRelation`
|
96
|
+
- `TypedAssociation::CollectionProxy` is included by per-model classes like `X::PrivateCollectionProxy`
|
97
|
+
|
98
|
+
Example:
|
99
|
+
```rb
|
100
|
+
class Foo < ActiveRecord::Base
|
101
|
+
has_many :bars
|
102
|
+
end
|
103
|
+
|
104
|
+
foo = Foo.new
|
105
|
+
foo.bars #=> Bar::PrivateCollectionProxy
|
106
|
+
|
107
|
+
#: (TypedAssociation::CollectionProxy[Bar]) -> void
|
108
|
+
def do_smth(rel); end
|
109
|
+
|
110
|
+
do_smth(foo.bars) # ok!
|
111
|
+
```
|
112
|
+
|
113
|
+
One common use case is working on child/parent model associations.
|
114
|
+
|
115
|
+
```rb
|
116
|
+
class Foo < ActiveRecord::Base
|
117
|
+
belongs_to :user
|
118
|
+
end
|
119
|
+
|
120
|
+
class Bar < Foo
|
121
|
+
belongs_to :manager
|
122
|
+
end
|
123
|
+
|
124
|
+
class User < ActiveRecord::Base
|
125
|
+
has_many :foos
|
126
|
+
end
|
127
|
+
|
128
|
+
class Manager < ActiveRecord::Base
|
129
|
+
has_many :bars
|
130
|
+
end
|
131
|
+
|
132
|
+
#: (TypedAssociation::CollectionProxy[Foo]) -> void
|
133
|
+
def do_smth_on_foos(rel); end
|
134
|
+
|
135
|
+
user = User.new
|
136
|
+
user.foos #=> Foo::PrivateCollectionProxy
|
137
|
+
do_smth_on_foos(user.foos) # ok!
|
138
|
+
|
139
|
+
user = Manager.new
|
140
|
+
user.bars #=> Bar::PrivateCollectionProxy
|
141
|
+
do_smth_on_foos(user.bars) # ok!
|
142
|
+
```
|
143
|
+
|
88
144
|
### ActiveRecord::Base::alias_association
|
89
145
|
|
90
146
|
This gem adds a new method called `alias_association` on ActiveRecord classes.
|
@@ -92,13 +148,13 @@ It lets you define aliases for getters and setters of `belongs_to` and `has_one`
|
|
92
148
|
|
93
149
|
Example:
|
94
150
|
```rb
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
151
|
+
class Foo < ApplicationRecord
|
152
|
+
belongs_to :user
|
153
|
+
alias_association :owner, :user
|
154
|
+
end
|
99
155
|
|
100
|
-
|
101
|
-
|
156
|
+
f = Foo.last
|
157
|
+
f.owner == f.user #=> true
|
102
158
|
```
|
103
159
|
|
104
160
|
### Rails::On::Sorbet::CurrentAttributes
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# typed: false
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'action_controller'
|
5
|
+
require 'active_support'
|
6
|
+
|
7
|
+
# Represents a `X::PrivateRelation` tapioca generated class, where `X` is an ActiveRecord model.
|
8
|
+
module TypedRelation
|
9
|
+
extend T::Generic
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def GroupChain(val) = val # rubocop:disable Naming/MethodName
|
13
|
+
def WhereChain(val) = val # rubocop:disable Naming/MethodName
|
14
|
+
end
|
15
|
+
|
16
|
+
module GroupChain
|
17
|
+
extend T::Generic
|
18
|
+
include TypedRelation
|
19
|
+
end
|
20
|
+
|
21
|
+
module WhereChain
|
22
|
+
extend T::Generic
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def TypedRelation(val) = val # rubocop:disable Style/TopLevelMethodDefinition,Naming/MethodName
|
27
|
+
|
28
|
+
# A namespace for typed ActiveRecord association objects.
|
29
|
+
module TypedAssociation
|
30
|
+
class << self
|
31
|
+
def Relation(val) = val # rubocop:disable Naming/MethodName
|
32
|
+
def CollectionProxy(val) = val # rubocop:disable Naming/MethodName
|
33
|
+
end
|
34
|
+
|
35
|
+
# Represents a `X::PrivateAssociationRelation` tapioca generated class, where `X` is an ActiveRecord model.
|
36
|
+
module Relation
|
37
|
+
extend T::Generic
|
38
|
+
|
39
|
+
class << self
|
40
|
+
def GroupChain(val) = val # rubocop:disable Naming/MethodName
|
41
|
+
def WhereChain(val) = val # rubocop:disable Naming/MethodName
|
42
|
+
def CollectionProxy(val) = val # rubocop:disable Naming/MethodName
|
43
|
+
end
|
44
|
+
|
45
|
+
module GroupChain
|
46
|
+
extend T::Generic
|
47
|
+
include Relation
|
48
|
+
end
|
49
|
+
|
50
|
+
module WhereChain
|
51
|
+
extend T::Generic
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
module CollectionProxy
|
56
|
+
extend T::Generic
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Tapioca
|
5
|
+
module Compilers
|
6
|
+
# Creates .rbi files with types for classes that use ActiveRecord relations
|
7
|
+
#: [ConstantType < singleton(::ActiveRecord::Base)]
|
8
|
+
class RailsOnSorbetActiveRecordRelations < Tapioca::Dsl::Compiler
|
9
|
+
class << self
|
10
|
+
# @override
|
11
|
+
#: -> T::Enumerable[Module]
|
12
|
+
def gather_constants
|
13
|
+
all_classes.select do |klass|
|
14
|
+
klass < ::ActiveRecord::Base
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# @override
|
20
|
+
#: -> void
|
21
|
+
def decorate
|
22
|
+
root.create_path(constant) do |klass|
|
23
|
+
private_relation = klass.create_class('PrivateRelation')
|
24
|
+
private_relation.create_include('::TypedRelation')
|
25
|
+
|
26
|
+
private_relation_group_chain = klass.create_class('PrivateRelationGroupChain')
|
27
|
+
private_relation_group_chain.create_include('::TypedRelation::GroupChain')
|
28
|
+
|
29
|
+
private_relation_where_chain = klass.create_class('PrivateRelationWhereChain')
|
30
|
+
private_relation_where_chain.create_include('::TypedRelation::WhereChain')
|
31
|
+
|
32
|
+
private_collection_proxy = klass.create_class('PrivateCollectionProxy')
|
33
|
+
private_collection_proxy.create_include('::TypedRelation::CollectionProxy')
|
34
|
+
|
35
|
+
|
36
|
+
private_association_relation = klass.create_class('PrivateAssociationRelation')
|
37
|
+
private_association_relation.create_include('::TypedAssociationRelation')
|
38
|
+
|
39
|
+
private_relation_group_chain = klass.create_class('PrivateAssociationRelationGroupChain')
|
40
|
+
private_relation_group_chain.create_include('::TypedAssociationRelation::GroupChain')
|
41
|
+
|
42
|
+
private_relation_where_chain = klass.create_class('PrivateAssociationRelationWhereChain')
|
43
|
+
private_relation_where_chain.create_include('::TypedAssociationRelation::WhereChain')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,944 @@
|
|
1
|
+
# typed: false
|
2
|
+
|
3
|
+
#: (ActiveRecord::Relation) -> TypedRelation[untyped]
|
4
|
+
def TypedRelation(val); end
|
5
|
+
|
6
|
+
# @abstract
|
7
|
+
module TypedCommonRelationMethods
|
8
|
+
Elem = type_member(:out)
|
9
|
+
|
10
|
+
# START CommonRelationMethods
|
11
|
+
|
12
|
+
sig { abstract.returns(T::Array[Elem]) }
|
13
|
+
def to_a; end
|
14
|
+
|
15
|
+
sig { abstract.returns(T::Array[Elem]) }
|
16
|
+
def to_ary; end
|
17
|
+
|
18
|
+
sig do
|
19
|
+
abstract.params(
|
20
|
+
block: T.nilable(T.proc.params(record: Elem).returns(T.untyped))
|
21
|
+
).returns(T::Boolean)
|
22
|
+
end
|
23
|
+
def any?(&block); end
|
24
|
+
|
25
|
+
sig { abstract.params(column_name: T.any(String, Symbol)).returns(T.any(Integer, Float, BigDecimal)) }
|
26
|
+
def average(column_name); end
|
27
|
+
|
28
|
+
sig do
|
29
|
+
params(
|
30
|
+
block: T.nilable(T.proc.params(object: Elem).void)
|
31
|
+
).returns(Elem)
|
32
|
+
end
|
33
|
+
sig do
|
34
|
+
params(
|
35
|
+
attributes: T::Array[T.untyped],
|
36
|
+
block: T.nilable(T.proc.params(object: Elem).void)
|
37
|
+
).returns(T::Array[Elem])
|
38
|
+
end
|
39
|
+
sig do
|
40
|
+
params(
|
41
|
+
attributes: T.untyped,
|
42
|
+
block: T.nilable(T.proc.params(object: Elem).void)
|
43
|
+
).returns(Elem)
|
44
|
+
end
|
45
|
+
def build(attributes = nil, &block); end
|
46
|
+
|
47
|
+
sig { abstract.params(operation: Symbol, column_name: T.any(String, Symbol)).returns(T.any(Integer, Float, BigDecimal)) }
|
48
|
+
def calculate(operation, column_name); end
|
49
|
+
|
50
|
+
sig { params(column_name: T.nilable(T.any(String, Symbol))).returns(Integer) }
|
51
|
+
sig do
|
52
|
+
params(
|
53
|
+
column_name: NilClass,
|
54
|
+
block: T.proc.params(object: Elem).void
|
55
|
+
).returns(Integer)
|
56
|
+
end
|
57
|
+
def count(column_name = nil, &block); end
|
58
|
+
|
59
|
+
sig do
|
60
|
+
params(
|
61
|
+
block: T.nilable(T.proc.params(object: Elem).void)
|
62
|
+
).returns(Elem)
|
63
|
+
end
|
64
|
+
sig do
|
65
|
+
params(
|
66
|
+
attributes: T::Array[T.untyped],
|
67
|
+
block: T.nilable(T.proc.params(object: Elem).void)
|
68
|
+
).returns(T::Array[Elem])
|
69
|
+
end
|
70
|
+
sig do
|
71
|
+
params(
|
72
|
+
attributes: T.untyped,
|
73
|
+
block: T.nilable(T.proc.params(object: Elem).void)
|
74
|
+
).returns(Elem)
|
75
|
+
end
|
76
|
+
def create(attributes = nil, &block); end
|
77
|
+
|
78
|
+
sig do
|
79
|
+
params(
|
80
|
+
block: T.nilable(T.proc.params(object: Elem).void)
|
81
|
+
).returns(Elem)
|
82
|
+
end
|
83
|
+
sig do
|
84
|
+
params(
|
85
|
+
attributes: T::Array[T.untyped],
|
86
|
+
block: T.nilable(T.proc.params(object: Elem).void)
|
87
|
+
).returns(T::Array[Elem])
|
88
|
+
end
|
89
|
+
sig do
|
90
|
+
params(
|
91
|
+
attributes: T.untyped,
|
92
|
+
block: T.nilable(T.proc.params(object: Elem).void)
|
93
|
+
).returns(Elem)
|
94
|
+
end
|
95
|
+
def create!(attributes = nil, &block); end
|
96
|
+
|
97
|
+
sig do
|
98
|
+
params(
|
99
|
+
attributes: T::Array[T.untyped],
|
100
|
+
block: T.nilable(T.proc.params(object: Elem).void)
|
101
|
+
).returns(T::Array[Elem])
|
102
|
+
end
|
103
|
+
sig do
|
104
|
+
params(
|
105
|
+
attributes: T.untyped,
|
106
|
+
block: T.nilable(T.proc.params(object: Elem).void)
|
107
|
+
).returns(Elem)
|
108
|
+
end
|
109
|
+
def create_or_find_by(attributes, &block); end
|
110
|
+
|
111
|
+
sig do
|
112
|
+
params(
|
113
|
+
attributes: T::Array[T.untyped],
|
114
|
+
block: T.nilable(T.proc.params(object: Elem).void)
|
115
|
+
).returns(T::Array[Elem])
|
116
|
+
end
|
117
|
+
sig do
|
118
|
+
params(
|
119
|
+
attributes: T.untyped,
|
120
|
+
block: T.nilable(T.proc.params(object: Elem).void)
|
121
|
+
).returns(Elem)
|
122
|
+
end
|
123
|
+
def create_or_find_by!(attributes, &block); end
|
124
|
+
|
125
|
+
sig { returns(T::Array[Elem]) }
|
126
|
+
def destroy_all; end
|
127
|
+
|
128
|
+
sig { params(conditions: T.untyped).returns(T::Boolean) }
|
129
|
+
def exists?(conditions = :none); end
|
130
|
+
|
131
|
+
sig { returns(T.nilable(Elem)) }
|
132
|
+
def fifth; end
|
133
|
+
|
134
|
+
sig { returns(Elem) }
|
135
|
+
def fifth!; end
|
136
|
+
|
137
|
+
sig do
|
138
|
+
params(
|
139
|
+
args: T.any(String, Symbol, ::ActiveSupport::Multibyte::Chars, T::Boolean, BigDecimal, Numeric, ::ActiveRecord::Type::Binary::Data, ::ActiveRecord::Type::Time::Value, Date, Time, ::ActiveSupport::Duration, T::Class[T.anything])
|
140
|
+
).returns(Elem)
|
141
|
+
end
|
142
|
+
sig do
|
143
|
+
params(
|
144
|
+
args: T::Array[T.any(String, Symbol, ::ActiveSupport::Multibyte::Chars, T::Boolean, BigDecimal, Numeric, ::ActiveRecord::Type::Binary::Data, ::ActiveRecord::Type::Time::Value, Date, Time, ::ActiveSupport::Duration, T::Class[T.anything])]
|
145
|
+
).returns(T::Enumerable[Elem])
|
146
|
+
end
|
147
|
+
sig do
|
148
|
+
params(
|
149
|
+
args: NilClass,
|
150
|
+
block: T.proc.params(object: Elem).void
|
151
|
+
).returns(T.nilable(Elem))
|
152
|
+
end
|
153
|
+
def find(args = nil, &block); end
|
154
|
+
|
155
|
+
sig { params(args: T.untyped).returns(T.nilable(Elem)) }
|
156
|
+
def find_by(*args); end
|
157
|
+
|
158
|
+
sig { params(args: T.untyped).returns(Elem) }
|
159
|
+
def find_by!(*args); end
|
160
|
+
|
161
|
+
sig do
|
162
|
+
params(
|
163
|
+
start: T.untyped,
|
164
|
+
finish: T.untyped,
|
165
|
+
batch_size: Integer,
|
166
|
+
error_on_ignore: T.untyped,
|
167
|
+
order: Symbol,
|
168
|
+
block: T.proc.params(object: Elem).void
|
169
|
+
).void
|
170
|
+
end
|
171
|
+
sig do
|
172
|
+
params(
|
173
|
+
start: T.untyped,
|
174
|
+
finish: T.untyped,
|
175
|
+
batch_size: Integer,
|
176
|
+
error_on_ignore: T.untyped,
|
177
|
+
order: Symbol
|
178
|
+
).returns(T::Enumerator[Elem])
|
179
|
+
end
|
180
|
+
def find_each(start: nil, finish: nil, batch_size: 1000, error_on_ignore: nil, order: :asc, &block); end
|
181
|
+
|
182
|
+
sig do
|
183
|
+
params(
|
184
|
+
start: T.untyped,
|
185
|
+
finish: T.untyped,
|
186
|
+
batch_size: Integer,
|
187
|
+
error_on_ignore: T.untyped,
|
188
|
+
order: Symbol,
|
189
|
+
block: T.proc.params(object: T::Array[Elem]).void
|
190
|
+
).void
|
191
|
+
end
|
192
|
+
sig do
|
193
|
+
params(
|
194
|
+
start: T.untyped,
|
195
|
+
finish: T.untyped,
|
196
|
+
batch_size: Integer,
|
197
|
+
error_on_ignore: T.untyped,
|
198
|
+
order: Symbol
|
199
|
+
).returns(T::Enumerator[T::Enumerator[Elem]])
|
200
|
+
end
|
201
|
+
def find_in_batches(start: nil, finish: nil, batch_size: 1000, error_on_ignore: nil, order: :asc, &block); end
|
202
|
+
|
203
|
+
sig do
|
204
|
+
params(
|
205
|
+
attributes: T::Array[T.untyped],
|
206
|
+
block: T.nilable(T.proc.params(object: Elem).void)
|
207
|
+
).returns(T::Array[Elem])
|
208
|
+
end
|
209
|
+
sig do
|
210
|
+
params(
|
211
|
+
attributes: T.untyped,
|
212
|
+
block: T.nilable(T.proc.params(object: Elem).void)
|
213
|
+
).returns(Elem)
|
214
|
+
end
|
215
|
+
def find_or_create_by(attributes, &block); end
|
216
|
+
|
217
|
+
sig do
|
218
|
+
params(
|
219
|
+
attributes: T::Array[T.untyped],
|
220
|
+
block: T.nilable(T.proc.params(object: Elem).void)
|
221
|
+
).returns(T::Array[Elem])
|
222
|
+
end
|
223
|
+
sig do
|
224
|
+
params(
|
225
|
+
attributes: T.untyped,
|
226
|
+
block: T.nilable(T.proc.params(object: Elem).void)
|
227
|
+
).returns(Elem)
|
228
|
+
end
|
229
|
+
def find_or_create_by!(attributes, &block); end
|
230
|
+
|
231
|
+
sig do
|
232
|
+
params(
|
233
|
+
attributes: T::Array[T.untyped],
|
234
|
+
block: T.nilable(T.proc.params(object: Elem).void)
|
235
|
+
).returns(T::Array[Elem])
|
236
|
+
end
|
237
|
+
sig do
|
238
|
+
params(
|
239
|
+
attributes: T.untyped,
|
240
|
+
block: T.nilable(T.proc.params(object: Elem).void)
|
241
|
+
).returns(Elem)
|
242
|
+
end
|
243
|
+
def find_or_initialize_by(attributes, &block); end
|
244
|
+
|
245
|
+
sig do
|
246
|
+
abstract.params(
|
247
|
+
signed_id: T.untyped,
|
248
|
+
purpose: T.untyped
|
249
|
+
).returns(T.nilable(Elem))
|
250
|
+
end
|
251
|
+
def find_signed(signed_id, purpose: nil); end
|
252
|
+
|
253
|
+
sig { abstract.params(signed_id: T.untyped, purpose: T.untyped).returns(Elem) }
|
254
|
+
def find_signed!(signed_id, purpose: nil); end
|
255
|
+
|
256
|
+
sig { abstract.params(arg: T.untyped, args: T.untyped).returns(Elem) }
|
257
|
+
def find_sole_by(arg, *args); end
|
258
|
+
|
259
|
+
sig { returns(T.nilable(Elem)) }
|
260
|
+
sig { params(limit: Integer).returns(T::Array[Elem]) }
|
261
|
+
def first(limit = nil); end
|
262
|
+
|
263
|
+
sig { abstract.returns(Elem) }
|
264
|
+
def first!; end
|
265
|
+
|
266
|
+
sig { abstract.returns(T.nilable(Elem)) }
|
267
|
+
def forty_two; end
|
268
|
+
|
269
|
+
sig { abstract.returns(Elem) }
|
270
|
+
def forty_two!; end
|
271
|
+
|
272
|
+
sig { abstract.returns(T.nilable(Elem)) }
|
273
|
+
def fourth; end
|
274
|
+
|
275
|
+
sig { abstract.returns(Elem) }
|
276
|
+
def fourth!; end
|
277
|
+
|
278
|
+
sig { abstract.returns(Array) }
|
279
|
+
def ids; end
|
280
|
+
|
281
|
+
sig do
|
282
|
+
params(
|
283
|
+
of: Integer,
|
284
|
+
start: T.untyped,
|
285
|
+
finish: T.untyped,
|
286
|
+
load: T.untyped,
|
287
|
+
error_on_ignore: T.untyped,
|
288
|
+
order: Symbol,
|
289
|
+
use_ranges: T.untyped,
|
290
|
+
block: T.proc.params(object: T.untyped).void
|
291
|
+
).void
|
292
|
+
end
|
293
|
+
sig do
|
294
|
+
params(
|
295
|
+
of: Integer,
|
296
|
+
start: T.untyped,
|
297
|
+
finish: T.untyped,
|
298
|
+
load: T.untyped,
|
299
|
+
error_on_ignore: T.untyped,
|
300
|
+
order: Symbol,
|
301
|
+
use_ranges: T.untyped
|
302
|
+
).returns(::ActiveRecord::Batches::BatchEnumerator)
|
303
|
+
end
|
304
|
+
def in_batches(of: 1000, start: nil, finish: nil, load: false, error_on_ignore: nil, order: :asc, use_ranges: nil, &block); end
|
305
|
+
|
306
|
+
sig { abstract.params(record: T.untyped).returns(T::Boolean) }
|
307
|
+
def include?(record); end
|
308
|
+
|
309
|
+
sig { returns(T.nilable(Elem)) }
|
310
|
+
sig { params(limit: Integer).returns(T::Array[Elem]) }
|
311
|
+
def last(limit = nil); end
|
312
|
+
|
313
|
+
sig { returns(Elem) }
|
314
|
+
def last!; end
|
315
|
+
|
316
|
+
sig do
|
317
|
+
abstract.params(
|
318
|
+
block: T.nilable(T.proc.params(record: Elem).returns(T.untyped))
|
319
|
+
).returns(T::Boolean)
|
320
|
+
end
|
321
|
+
def many?(&block); end
|
322
|
+
|
323
|
+
sig { abstract.params(column_name: T.any(String, Symbol)).returns(T.untyped) }
|
324
|
+
def maximum(column_name); end
|
325
|
+
|
326
|
+
sig { abstract.params(record: T.untyped).returns(T::Boolean) }
|
327
|
+
def member?(record); end
|
328
|
+
|
329
|
+
sig { abstract.params(column_name: T.any(String, Symbol)).returns(T.untyped) }
|
330
|
+
def minimum(column_name); end
|
331
|
+
|
332
|
+
sig do
|
333
|
+
params(
|
334
|
+
block: T.nilable(T.proc.params(object: Elem).void)
|
335
|
+
).returns(Elem)
|
336
|
+
end
|
337
|
+
sig do
|
338
|
+
params(
|
339
|
+
attributes: T::Array[T.untyped],
|
340
|
+
block: T.nilable(T.proc.params(object: Elem).void)
|
341
|
+
).returns(T::Array[Elem])
|
342
|
+
end
|
343
|
+
sig do
|
344
|
+
params(
|
345
|
+
attributes: T.untyped,
|
346
|
+
block: T.nilable(T.proc.params(object: Elem).void)
|
347
|
+
).returns(Elem)
|
348
|
+
end
|
349
|
+
def new(attributes = nil, &block); end
|
350
|
+
|
351
|
+
sig do
|
352
|
+
abstract.params(
|
353
|
+
block: T.nilable(T.proc.params(record: Elem).returns(T.untyped))
|
354
|
+
).returns(T::Boolean)
|
355
|
+
end
|
356
|
+
def none?(&block); end
|
357
|
+
|
358
|
+
sig do
|
359
|
+
abstract.params(
|
360
|
+
block: T.nilable(T.proc.params(record: Elem).returns(T.untyped))
|
361
|
+
).returns(T::Boolean)
|
362
|
+
end
|
363
|
+
def one?(&block); end
|
364
|
+
|
365
|
+
sig { abstract.params(column_names: T.untyped).returns(T.untyped) }
|
366
|
+
def pick(*column_names); end
|
367
|
+
|
368
|
+
sig { abstract.params(column_names: T.untyped).returns(T.untyped) }
|
369
|
+
def pluck(*column_names); end
|
370
|
+
|
371
|
+
sig { abstract.returns(T.nilable(Elem)) }
|
372
|
+
def second; end
|
373
|
+
|
374
|
+
sig { abstract.returns(Elem) }
|
375
|
+
def second!; end
|
376
|
+
|
377
|
+
sig { abstract.returns(T.nilable(Elem)) }
|
378
|
+
def second_to_last; end
|
379
|
+
|
380
|
+
sig { abstract.returns(Elem) }
|
381
|
+
def second_to_last!; end
|
382
|
+
|
383
|
+
sig { abstract.returns(Elem) }
|
384
|
+
def sole; end
|
385
|
+
|
386
|
+
sig { params(initial_value_or_column: T.untyped).returns(T.any(Integer, Float, BigDecimal)) }
|
387
|
+
sig do
|
388
|
+
type_parameters(:U)
|
389
|
+
.params(
|
390
|
+
initial_value_or_column: T.nilable(T.type_parameter(:U)),
|
391
|
+
block: T.proc.params(object: Elem).returns(T.type_parameter(:U))
|
392
|
+
).returns(T.type_parameter(:U))
|
393
|
+
end
|
394
|
+
def sum(initial_value_or_column = nil, &block); end
|
395
|
+
|
396
|
+
sig { returns(T.nilable(Elem)) }
|
397
|
+
sig { params(limit: Integer).returns(T::Array[Elem]) }
|
398
|
+
def take(limit = nil); end
|
399
|
+
|
400
|
+
sig { abstract.returns(Elem) }
|
401
|
+
def take!; end
|
402
|
+
|
403
|
+
sig { abstract.returns(T.nilable(Elem)) }
|
404
|
+
def third; end
|
405
|
+
|
406
|
+
sig { abstract.returns(Elem) }
|
407
|
+
def third!; end
|
408
|
+
|
409
|
+
sig { abstract.returns(T.nilable(Elem)) }
|
410
|
+
def third_to_last; end
|
411
|
+
|
412
|
+
sig { abstract.returns(Elem) }
|
413
|
+
def third_to_last!; end
|
414
|
+
|
415
|
+
# END CommonRelationMethods
|
416
|
+
end
|
417
|
+
|
418
|
+
# @abstract
|
419
|
+
# @requires_ancestor: ActiveRecord::Relation
|
420
|
+
module TypedRelation
|
421
|
+
Elem = type_member(:out)
|
422
|
+
|
423
|
+
class << self
|
424
|
+
#: (ActiveRecord::Relation) -> GroupChain[untyped]
|
425
|
+
def GroupChain(val); end
|
426
|
+
#: (ActiveRecord::QueryMethods::WhereChain) -> WhereChain[untyped]
|
427
|
+
def WhereChain(val); end
|
428
|
+
end
|
429
|
+
|
430
|
+
# @abstract
|
431
|
+
module GroupChain
|
432
|
+
include TypedRelation
|
433
|
+
|
434
|
+
Elem = type_member(:out)
|
435
|
+
|
436
|
+
sig { abstract.params(column_name: T.any(String, Symbol)).returns(T::Hash[T.untyped, T.any(Integer, Float, BigDecimal)]) }
|
437
|
+
def average(column_name); end
|
438
|
+
|
439
|
+
sig do
|
440
|
+
abstract.params(
|
441
|
+
operation: Symbol,
|
442
|
+
column_name: T.any(String, Symbol)
|
443
|
+
).returns(T::Hash[T.untyped, T.any(Integer, Float, BigDecimal)])
|
444
|
+
end
|
445
|
+
def calculate(operation, column_name); end
|
446
|
+
|
447
|
+
sig { abstract.params(column_name: T.untyped).returns(T::Hash[T.untyped, Integer]) }
|
448
|
+
def count(column_name = nil); end
|
449
|
+
|
450
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
451
|
+
def having(*args, &blk); end
|
452
|
+
|
453
|
+
sig { abstract.params(column_name: T.any(String, Symbol)).returns(T::Hash[T.untyped, T.untyped]) }
|
454
|
+
def maximum(column_name); end
|
455
|
+
|
456
|
+
sig { abstract.params(column_name: T.any(String, Symbol)).returns(T::Hash[T.untyped, T.untyped]) }
|
457
|
+
def minimum(column_name); end
|
458
|
+
|
459
|
+
sig { returns(T::Hash[T.untyped, Integer]) }
|
460
|
+
def size; end
|
461
|
+
|
462
|
+
sig do
|
463
|
+
abstract.params(
|
464
|
+
column_name: T.nilable(T.any(String, Symbol)),
|
465
|
+
block: T.nilable(T.proc.params(record: T.untyped).returns(T.untyped))
|
466
|
+
).returns(T::Hash[T.untyped, T.any(Integer, Float, BigDecimal)])
|
467
|
+
end
|
468
|
+
def sum(column_name = nil, &block); end
|
469
|
+
end
|
470
|
+
|
471
|
+
# @requires_ancestor: ::ActiveRecord::QueryMethods::WhereChain
|
472
|
+
# @abstract
|
473
|
+
module WhereChain
|
474
|
+
Elem = type_member(:out)
|
475
|
+
|
476
|
+
sig { abstract.params(args: T.untyped).returns(TypedRelation[Elem]) }
|
477
|
+
def associated(*args); end
|
478
|
+
|
479
|
+
sig { abstract.params(args: T.untyped).returns(TypedRelation[Elem]) }
|
480
|
+
def missing(*args); end
|
481
|
+
|
482
|
+
sig { abstract.params(opts: T.untyped, rest: T.untyped).returns(TypedRelation[Elem]) }
|
483
|
+
def not(opts, *rest); end
|
484
|
+
end
|
485
|
+
|
486
|
+
include TypedCommonRelationMethods
|
487
|
+
|
488
|
+
# START GeneratedRelationMethods
|
489
|
+
|
490
|
+
sig { abstract.returns(T.self_type) }
|
491
|
+
def all; end
|
492
|
+
|
493
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
494
|
+
def and(*args, &blk); end
|
495
|
+
|
496
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
497
|
+
def annotate(*args, &blk); end
|
498
|
+
|
499
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
500
|
+
def arel_columns(*args, &blk); end
|
501
|
+
|
502
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
503
|
+
def create_with(*args, &blk); end
|
504
|
+
|
505
|
+
sig { abstract.params(value: T::Boolean).returns(T.self_type) }
|
506
|
+
def distinct(value = true); end
|
507
|
+
|
508
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
509
|
+
def eager_load(*args, &blk); end
|
510
|
+
|
511
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
512
|
+
def except(*args, &blk); end
|
513
|
+
|
514
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
515
|
+
def excluding(*args, &blk); end
|
516
|
+
|
517
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
518
|
+
def extending(*args, &blk); end
|
519
|
+
|
520
|
+
sig { abstract.params(association: Symbol).returns(T::Array[T.untyped]) }
|
521
|
+
def extract_associated(association); end
|
522
|
+
|
523
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
524
|
+
def from(*args, &blk); end
|
525
|
+
|
526
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(GroupChain[Elem]) }
|
527
|
+
def group(*args, &blk); end
|
528
|
+
|
529
|
+
sig { params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
530
|
+
def having(*args, &blk); end
|
531
|
+
|
532
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
533
|
+
def in_order_of(*args, &blk); end
|
534
|
+
|
535
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
536
|
+
def includes(*args, &blk); end
|
537
|
+
|
538
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
539
|
+
def invert_where(*args, &blk); end
|
540
|
+
|
541
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
542
|
+
def joins(*args, &blk); end
|
543
|
+
|
544
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
545
|
+
def left_joins(*args, &blk); end
|
546
|
+
|
547
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
548
|
+
def left_outer_joins(*args, &blk); end
|
549
|
+
|
550
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
551
|
+
def limit(*args, &blk); end
|
552
|
+
|
553
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
554
|
+
def lock(*args, &blk); end
|
555
|
+
|
556
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
557
|
+
def merge(*args, &blk); end
|
558
|
+
|
559
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
560
|
+
def none(*args, &blk); end
|
561
|
+
|
562
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
563
|
+
def null_relation?(*args, &blk); end
|
564
|
+
|
565
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
566
|
+
def offset(*args, &blk); end
|
567
|
+
|
568
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
569
|
+
def only(*args, &blk); end
|
570
|
+
|
571
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
572
|
+
def optimizer_hints(*args, &blk); end
|
573
|
+
|
574
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
575
|
+
def or(*args, &blk); end
|
576
|
+
|
577
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
578
|
+
def order(*args, &blk); end
|
579
|
+
|
580
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
581
|
+
def preload(*args, &blk); end
|
582
|
+
|
583
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
584
|
+
def readonly(*args, &blk); end
|
585
|
+
|
586
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
587
|
+
def references(*args, &blk); end
|
588
|
+
|
589
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
590
|
+
def regroup(*args, &blk); end
|
591
|
+
|
592
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
593
|
+
def reorder(*args, &blk); end
|
594
|
+
|
595
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
596
|
+
def reselect(*args, &blk); end
|
597
|
+
|
598
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
599
|
+
def reverse_order(*args, &blk); end
|
600
|
+
|
601
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
602
|
+
def rewhere(*args, &blk); end
|
603
|
+
|
604
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
605
|
+
def sanitize_forbidden_attributes(*args, &blk); end
|
606
|
+
|
607
|
+
sig { params(args: T.untyped).returns(T.self_type) }
|
608
|
+
sig do
|
609
|
+
params(
|
610
|
+
blk: T.proc.params(record: Elem).returns(BasicObject)
|
611
|
+
).returns(T::Array[Elem])
|
612
|
+
end
|
613
|
+
def select(*args, &blk); end
|
614
|
+
|
615
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
616
|
+
def strict_loading(*args, &blk); end
|
617
|
+
|
618
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
619
|
+
def structurally_compatible?(*args, &blk); end
|
620
|
+
|
621
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
622
|
+
def uniq!(*args, &blk); end
|
623
|
+
|
624
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
625
|
+
def unscope(*args, &blk); end
|
626
|
+
|
627
|
+
sig { returns(WhereChain[Elem]) }
|
628
|
+
sig { params(args: T.untyped).returns(T.self_type) }
|
629
|
+
def where(*args); end
|
630
|
+
|
631
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
632
|
+
def with(*args, &blk); end
|
633
|
+
|
634
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
635
|
+
def with_recursive(*args, &blk); end
|
636
|
+
|
637
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
638
|
+
def without(*args, &blk); end
|
639
|
+
end
|
640
|
+
|
641
|
+
# @abstract
|
642
|
+
module TypedGeneratedAssociationRelationMethods
|
643
|
+
Elem = type_member(:out)
|
644
|
+
|
645
|
+
sig { abstract.returns(T::Array[Elem]) }
|
646
|
+
def to_a; end
|
647
|
+
|
648
|
+
sig { abstract.returns(T::Array[Elem]) }
|
649
|
+
def to_ary; end
|
650
|
+
|
651
|
+
sig { abstract.returns(T.self_type) }
|
652
|
+
def all; end
|
653
|
+
|
654
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
655
|
+
def and(*args, &blk); end
|
656
|
+
|
657
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
658
|
+
def annotate(*args, &blk); end
|
659
|
+
|
660
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
661
|
+
def arel_columns(*args, &blk); end
|
662
|
+
|
663
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
664
|
+
def create_with(*args, &blk); end
|
665
|
+
|
666
|
+
sig { abstract.params(value: T::Boolean).returns(T.self_type) }
|
667
|
+
def distinct(value = true); end
|
668
|
+
|
669
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
670
|
+
def eager_load(*args, &blk); end
|
671
|
+
|
672
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
673
|
+
def except(*args, &blk); end
|
674
|
+
|
675
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
676
|
+
def excluding(*args, &blk); end
|
677
|
+
|
678
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
679
|
+
def extending(*args, &blk); end
|
680
|
+
|
681
|
+
sig { abstract.params(association: Symbol).returns(T::Array[T.untyped]) }
|
682
|
+
def extract_associated(association); end
|
683
|
+
|
684
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
685
|
+
def from(*args, &blk); end
|
686
|
+
|
687
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(TypedAssociation::Relation::GroupChain[Elem]) }
|
688
|
+
def group(*args, &blk); end
|
689
|
+
|
690
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
691
|
+
def having(*args, &blk); end
|
692
|
+
|
693
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
694
|
+
def in_order_of(*args, &blk); end
|
695
|
+
|
696
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
697
|
+
def includes(*args, &blk); end
|
698
|
+
|
699
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
700
|
+
def invert_where(*args, &blk); end
|
701
|
+
|
702
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
703
|
+
def joins(*args, &blk); end
|
704
|
+
|
705
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
706
|
+
def left_joins(*args, &blk); end
|
707
|
+
|
708
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
709
|
+
def left_outer_joins(*args, &blk); end
|
710
|
+
|
711
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
712
|
+
def limit(*args, &blk); end
|
713
|
+
|
714
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
715
|
+
def lock(*args, &blk); end
|
716
|
+
|
717
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
718
|
+
def merge(*args, &blk); end
|
719
|
+
|
720
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
721
|
+
def none(*args, &blk); end
|
722
|
+
|
723
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
724
|
+
def null_relation?(*args, &blk); end
|
725
|
+
|
726
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
727
|
+
def offset(*args, &blk); end
|
728
|
+
|
729
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
730
|
+
def only(*args, &blk); end
|
731
|
+
|
732
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
733
|
+
def optimizer_hints(*args, &blk); end
|
734
|
+
|
735
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
736
|
+
def or(*args, &blk); end
|
737
|
+
|
738
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
739
|
+
def order(*args, &blk); end
|
740
|
+
|
741
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
742
|
+
def preload(*args, &blk); end
|
743
|
+
|
744
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
745
|
+
def readonly(*args, &blk); end
|
746
|
+
|
747
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
748
|
+
def references(*args, &blk); end
|
749
|
+
|
750
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
751
|
+
def regroup(*args, &blk); end
|
752
|
+
|
753
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
754
|
+
def reorder(*args, &blk); end
|
755
|
+
|
756
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
757
|
+
def reselect(*args, &blk); end
|
758
|
+
|
759
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
760
|
+
def reverse_order(*args, &blk); end
|
761
|
+
|
762
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
763
|
+
def rewhere(*args, &blk); end
|
764
|
+
|
765
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
766
|
+
def sanitize_forbidden_attributes(*args, &blk); end
|
767
|
+
|
768
|
+
sig { params(args: T.untyped).returns(T.self_type) }
|
769
|
+
sig do
|
770
|
+
params(
|
771
|
+
blk: T.proc.params(record: Elem).returns(BasicObject)
|
772
|
+
).returns(T::Array[Elem])
|
773
|
+
end
|
774
|
+
def select(*args, &blk); end
|
775
|
+
|
776
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
777
|
+
def strict_loading(*args, &blk); end
|
778
|
+
|
779
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
780
|
+
def structurally_compatible?(*args, &blk); end
|
781
|
+
|
782
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
783
|
+
def uniq!(*args, &blk); end
|
784
|
+
|
785
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
786
|
+
def unscope(*args, &blk); end
|
787
|
+
|
788
|
+
sig { returns(TypedAssociation::Relation::WhereChain[Elem]) }
|
789
|
+
sig { params(args: T.untyped).returns(T.self_type) }
|
790
|
+
def where(*args); end
|
791
|
+
|
792
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
793
|
+
def with(*args, &blk); end
|
794
|
+
|
795
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
796
|
+
def with_recursive(*args, &blk); end
|
797
|
+
|
798
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
799
|
+
def without(*args, &blk); end
|
800
|
+
end
|
801
|
+
|
802
|
+
module TypedAssociation
|
803
|
+
class << self
|
804
|
+
#: (::ActiveRecord::Relation) -> Relation[untyped]
|
805
|
+
def Relation(val); end
|
806
|
+
#: (::ActiveRecord::Associations::CollectionProxy) -> CollectionProxy[untyped]
|
807
|
+
def CollectionProxy(val); end
|
808
|
+
end
|
809
|
+
|
810
|
+
# @abstract
|
811
|
+
# @requires_ancestor: ActiveRecord::AssociationRelation
|
812
|
+
module Relation
|
813
|
+
include TypedCommonRelationMethods
|
814
|
+
include TypedGeneratedAssociationRelationMethods
|
815
|
+
|
816
|
+
Elem = type_member(:out)
|
817
|
+
|
818
|
+
class << self
|
819
|
+
#: (ActiveRecord::Relation) -> GroupChain[untyped]
|
820
|
+
def GroupChain(val); end
|
821
|
+
#: (ActiveRecord::QueryMethods::WhereChain) -> WhereChain[untyped]
|
822
|
+
def WhereChain(val); end
|
823
|
+
end
|
824
|
+
|
825
|
+
# @requires_ancestor: ::ActiveRecord::QueryMethods::WhereChain
|
826
|
+
# @abstract
|
827
|
+
module WhereChain
|
828
|
+
Elem = type_member(:out)
|
829
|
+
|
830
|
+
sig { abstract.params(args: T.untyped).returns(Relation[Elem]) }
|
831
|
+
def associated(*args); end
|
832
|
+
|
833
|
+
sig { abstract.params(args: T.untyped).returns(Relation[Elem]) }
|
834
|
+
def missing(*args); end
|
835
|
+
|
836
|
+
sig { abstract.params(opts: T.untyped, rest: T.untyped).returns(Relation[Elem]) }
|
837
|
+
def not(opts, *rest); end
|
838
|
+
end
|
839
|
+
|
840
|
+
# @abstract
|
841
|
+
module GroupChain
|
842
|
+
include Relation
|
843
|
+
|
844
|
+
Elem = type_member(:out)
|
845
|
+
|
846
|
+
sig { abstract.params(column_name: T.any(String, Symbol)).returns(T::Hash[T.untyped, T.any(Integer, Float, BigDecimal)]) }
|
847
|
+
def average(column_name); end
|
848
|
+
|
849
|
+
sig do
|
850
|
+
abstract.params(
|
851
|
+
operation: Symbol,
|
852
|
+
column_name: T.any(String, Symbol)
|
853
|
+
).returns(T::Hash[T.untyped, T.any(Integer, Float, BigDecimal)])
|
854
|
+
end
|
855
|
+
def calculate(operation, column_name); end
|
856
|
+
|
857
|
+
sig { abstract.params(column_name: T.untyped).returns(T::Hash[T.untyped, Integer]) }
|
858
|
+
def count(column_name = nil); end
|
859
|
+
|
860
|
+
sig { abstract.params(args: T.untyped, blk: T.untyped).returns(T.self_type) }
|
861
|
+
def having(*args, &blk); end
|
862
|
+
|
863
|
+
sig { abstract.params(column_name: T.any(String, Symbol)).returns(T::Hash[T.untyped, T.untyped]) }
|
864
|
+
def maximum(column_name); end
|
865
|
+
|
866
|
+
sig { abstract.params(column_name: T.any(String, Symbol)).returns(T::Hash[T.untyped, T.untyped]) }
|
867
|
+
def minimum(column_name); end
|
868
|
+
|
869
|
+
sig { abstract.returns(T::Hash[T.untyped, Integer]) }
|
870
|
+
def size; end
|
871
|
+
|
872
|
+
sig do
|
873
|
+
abstract.params(
|
874
|
+
column_name: T.nilable(T.any(String, Symbol)),
|
875
|
+
block: T.nilable(T.proc.params(record: T.untyped).returns(T.untyped))
|
876
|
+
).returns(T::Hash[T.untyped, T.any(Integer, Float, BigDecimal)])
|
877
|
+
end
|
878
|
+
def sum(column_name = nil, &block); end
|
879
|
+
end
|
880
|
+
end
|
881
|
+
|
882
|
+
# @requires_ancestor: ActiveRecord::Associations::CollectionProxy
|
883
|
+
# @abstract
|
884
|
+
module CollectionProxy
|
885
|
+
include TypedCommonRelationMethods
|
886
|
+
include TypedGeneratedAssociationRelationMethods
|
887
|
+
|
888
|
+
Elem = type_member(:out)
|
889
|
+
|
890
|
+
sig do
|
891
|
+
abstract.params(
|
892
|
+
records: T.any(Elem, T::Enumerable[T.any(Elem, T::Enumerable[Elem])])
|
893
|
+
).returns(T.self_type)
|
894
|
+
end
|
895
|
+
def <<(*records); end
|
896
|
+
|
897
|
+
sig do
|
898
|
+
abstract.params(
|
899
|
+
records: T.any(Elem, T::Enumerable[T.any(Elem, T::Enumerable[Elem])])
|
900
|
+
).returns(T.self_type)
|
901
|
+
end
|
902
|
+
def append(*records); end
|
903
|
+
|
904
|
+
sig { abstract.returns(T.self_type) }
|
905
|
+
def clear; end
|
906
|
+
|
907
|
+
sig do
|
908
|
+
abstract.params(
|
909
|
+
records: T.any(Elem, T::Enumerable[T.any(Elem, T::Enumerable[Elem])])
|
910
|
+
).returns(T.self_type)
|
911
|
+
end
|
912
|
+
def concat(*records); end
|
913
|
+
|
914
|
+
sig { returns(T::Array[Elem]) }
|
915
|
+
def load_target; end
|
916
|
+
|
917
|
+
sig do
|
918
|
+
abstract.params(
|
919
|
+
records: T.any(Elem, T::Enumerable[T.any(Elem, T::Enumerable[Elem])])
|
920
|
+
).returns(T.self_type)
|
921
|
+
end
|
922
|
+
def prepend(*records); end
|
923
|
+
|
924
|
+
sig do
|
925
|
+
abstract.params(
|
926
|
+
records: T.any(Elem, T::Enumerable[T.any(Elem, T::Enumerable[Elem])])
|
927
|
+
).returns(T.self_type)
|
928
|
+
end
|
929
|
+
def push(*records); end
|
930
|
+
|
931
|
+
sig do
|
932
|
+
abstract.params(
|
933
|
+
other_array: T.any(Elem, T::Enumerable[T.any(Elem, T::Enumerable[Elem])])
|
934
|
+
).returns(T::Array[Elem])
|
935
|
+
end
|
936
|
+
def replace(other_array); end
|
937
|
+
|
938
|
+
sig { abstract.returns(TypedAssociation::Relation[Elem]) }
|
939
|
+
def scope; end
|
940
|
+
|
941
|
+
sig { abstract.returns(T::Array[Elem]) }
|
942
|
+
def target; end
|
943
|
+
end
|
944
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-on-sorbet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mateusz Drewniak
|
@@ -69,7 +69,9 @@ files:
|
|
69
69
|
- lib/rails/on/sorbet/current_attributes.rb
|
70
70
|
- lib/rails/on/sorbet/map.rb
|
71
71
|
- lib/rails/on/sorbet/timelike.rb
|
72
|
+
- lib/rails/on/sorbet/typed_relation.rb
|
72
73
|
- lib/rails/on/sorbet/version.rb
|
74
|
+
- lib/tapioca/dsl/compilers/rails_on_sorbet_active_record.rb
|
73
75
|
- lib/tapioca/dsl/compilers/rails_on_sorbet_active_record_serializer.rb
|
74
76
|
- lib/tapioca/dsl/compilers/rails_on_sorbet_alias_association.rb
|
75
77
|
- lib/tapioca/dsl/compilers/rails_on_sorbet_currrent_attributes.rb
|
@@ -81,6 +83,7 @@ files:
|
|
81
83
|
- rbi/map.rbi
|
82
84
|
- rbi/numeric.rbi
|
83
85
|
- rbi/set.rbi
|
86
|
+
- rbi/typed_relation.rbi
|
84
87
|
homepage: https://github.com/espago/rails-on_sorbet
|
85
88
|
licenses: []
|
86
89
|
metadata:
|