rails-on-sorbet 0.3.2 → 0.3.4
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 +15 -0
- data/lib/rails/on/sorbet/map.rb +3 -0
- data/lib/rails/on/sorbet/typed_relation.rb +1 -0
- data/lib/rails/on/sorbet/version.rb +1 -1
- data/lib/rails/on/sorbet.rb +1 -0
- data/lib/tapioca/dsl/compilers/rails_on_sorbet_active_record.rb +10 -7
- data/rbi/map.rbi +26 -0
- data/rbi/typed_relation.rbi +5 -0
- 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: f489d9f4fc449469fc2c648b63cce27cf7f6765cf119003037567414d8d82554
|
4
|
+
data.tar.gz: 16383eef9597808df2fe6e1b044ded34c3a3d1cbfcb26f0b029a30e0195171d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ad359e0b378b16ab174854a6a8d552d17b17eb82702c92e4fb06fb6919e42bc543141832c9d91b8be3faa9aa6dcd081e01060484fe4ffb80731d2542730431a
|
7
|
+
data.tar.gz: 3319c64c51f3002bed9d4016aef5c9d4d1216e508212b2eeee6d4190ee792aedbf470cc2caca698eb3dac232ded938fda41452d45a3076528ce98a73ee4b7bd5
|
data/CHANGELOG.md
CHANGED
@@ -12,6 +12,21 @@ 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.4] - 21.10.2025
|
16
|
+
|
17
|
+
[Diff](https://github.com/espago/rails-on-sorbet/compare/v0.3.3...v0.3.4)
|
18
|
+
|
19
|
+
### Changes
|
20
|
+
- Add `Map::Params`
|
21
|
+
- Require `TypedRelation` automatically
|
22
|
+
|
23
|
+
## [0.3.3] - 20.10.2025
|
24
|
+
|
25
|
+
[Diff](https://github.com/espago/rails-on-sorbet/compare/v0.3.2...v0.3.3)
|
26
|
+
|
27
|
+
### Changes
|
28
|
+
- Fix tapioca compiler and subtyping for `TypedRelation`
|
29
|
+
|
15
30
|
## [0.3.2] - 20.10.2025
|
16
31
|
|
17
32
|
[Diff](https://github.com/espago/rails-on-sorbet/compare/v0.3.1...v0.3.2)
|
data/lib/rails/on/sorbet/map.rb
CHANGED
data/lib/rails/on/sorbet.rb
CHANGED
@@ -20,26 +20,29 @@ module Tapioca
|
|
20
20
|
#: -> void
|
21
21
|
def decorate
|
22
22
|
root.create_path(constant) do |klass|
|
23
|
-
private_relation = klass.create_class('PrivateRelation')
|
23
|
+
private_relation = klass.create_class('PrivateRelation', superclass_name: '::ActiveRecord::Relation')
|
24
24
|
private_relation.create_include('::TypedRelation')
|
25
25
|
|
26
|
-
private_relation_group_chain = klass.create_class('PrivateRelationGroupChain'
|
26
|
+
private_relation_group_chain = klass.create_class('PrivateRelationGroupChain',
|
27
|
+
superclass_name: 'PrivateRelation',)
|
27
28
|
private_relation_group_chain.create_include('::TypedRelation::GroupChain')
|
28
29
|
|
29
|
-
private_relation_where_chain = klass.create_class('PrivateRelationWhereChain')
|
30
|
+
private_relation_where_chain = klass.create_class('PrivateRelationWhereChain', superclass_name: '::ActiveRecord::QueryMethods::WhereChain')
|
30
31
|
private_relation_where_chain.create_include('::TypedRelation::WhereChain')
|
31
32
|
|
32
33
|
|
33
|
-
private_association_relation = klass.create_class('PrivateAssociationRelation')
|
34
|
+
private_association_relation = klass.create_class('PrivateAssociationRelation', superclass_name: '::ActiveRecord::AssociationRelation')
|
34
35
|
private_association_relation.create_include('::TypedAssociation::Relation')
|
35
36
|
|
36
|
-
private_relation_group_chain = klass.create_class('PrivateAssociationRelationGroupChain'
|
37
|
+
private_relation_group_chain = klass.create_class('PrivateAssociationRelationGroupChain',
|
38
|
+
superclass_name: 'PrivateAssociationRelation',)
|
37
39
|
private_relation_group_chain.create_include('::TypedAssociation::Relation::GroupChain')
|
38
40
|
|
39
|
-
private_relation_where_chain = klass.create_class('PrivateAssociationRelationWhereChain'
|
41
|
+
private_relation_where_chain = klass.create_class('PrivateAssociationRelationWhereChain',
|
42
|
+
superclass_name: '::ActiveRecord::QueryMethods::WhereChain',)
|
40
43
|
private_relation_where_chain.create_include('::TypedAssociation::Relation::WhereChain')
|
41
44
|
|
42
|
-
private_collection_proxy = klass.create_class('PrivateCollectionProxy')
|
45
|
+
private_collection_proxy = klass.create_class('PrivateCollectionProxy', superclass_name: '::ActiveRecord::Associations::CollectionProxy')
|
43
46
|
private_collection_proxy.create_include('::TypedAssociation::CollectionProxy')
|
44
47
|
end
|
45
48
|
end
|
data/rbi/map.rbi
CHANGED
@@ -4,6 +4,32 @@
|
|
4
4
|
#: (ActionController::Parameters | ActiveSupport::HashWithIndifferentAccess) -> Map[String | Symbol, untyped]
|
5
5
|
def Map(val); end
|
6
6
|
|
7
|
+
# `Map` represents a hash-like object
|
8
|
+
# Use the `Map` type in a signature.
|
9
|
+
#
|
10
|
+
# #: (Map[Symbol | String, Integer]) -> void
|
11
|
+
# def foo(m)
|
12
|
+
# m["foo"] #=> Integer?
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# hash = { "foo" => 4 } #: Hash[String, Integer]
|
16
|
+
# m = Map(hash) #=> Map[Symbol | String, Integer]
|
17
|
+
# foo(m) # OK
|
18
|
+
#
|
19
|
+
# hash = { "foo" => 4 }.with_indifferent_access # => ActiveSupport::HashWithIndifferentAccess
|
20
|
+
# m = Map(hash) #=> Map[Symbol | String, untyped]
|
21
|
+
# foo(m) # OK
|
22
|
+
#
|
23
|
+
# params = ActionController::Parameters.new # => ActionController::Parameters
|
24
|
+
# m = Map(params) #=> Map[Symbol | String, untyped]
|
25
|
+
# foo(m) # OK
|
26
|
+
#
|
27
|
+
# Cast a `Hash`, `ActionController::Parameters` or `ActiveSupport::HashWithIndifferentAccess`
|
28
|
+
# to a `Map`. The `Map` type defines common methods shared between these hash-like types.
|
29
|
+
#
|
30
|
+
# Due to current Sorbet limitations, hash-like types cannot directly implement the `Map` interface.
|
31
|
+
# The `Map` method provides a way to cast between hash-like types and `Map` to enable type-safe usage.
|
32
|
+
#
|
7
33
|
# @requires_ancestor: Object
|
8
34
|
# @abstract
|
9
35
|
#: [out K, out V]
|
data/rbi/typed_relation.rbi
CHANGED
@@ -417,6 +417,8 @@ module TypedCommonRelationMethods
|
|
417
417
|
# END CommonRelationMethods
|
418
418
|
end
|
419
419
|
|
420
|
+
# Represents a typed `ActiveRecord::Relation`.
|
421
|
+
#
|
420
422
|
# @abstract
|
421
423
|
module TypedRelation
|
422
424
|
extend T::Generic
|
@@ -884,9 +886,12 @@ module TypedAssociation
|
|
884
886
|
end
|
885
887
|
end
|
886
888
|
|
889
|
+
# Represents a typed `ActiveRecord::Associations::CollectionProxy`
|
890
|
+
#
|
887
891
|
# @abstract
|
888
892
|
module CollectionProxy
|
889
893
|
extend T::Generic
|
894
|
+
include TypedRelation
|
890
895
|
include TypedCommonRelationMethods
|
891
896
|
include TypedGeneratedAssociationRelationMethods
|
892
897
|
|