rails-on-sorbet 0.3.5 → 0.4.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 +14 -0
- data/README.md +3 -0
- data/lib/rails/on/sorbet/map.rb +1 -1
- data/lib/rails/on/sorbet/version.rb +1 -1
- data/lib/tapioca/dsl/compilers/rails_on_sorbet_active_record.rb +12 -7
- data/lib/tapioca/dsl/compilers/rails_on_sorbet_active_record_serializer.rb +3 -3
- data/rbi/map.rbi +2 -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: c535a249d20ba0cdc051763834fdb0cba1acd23604a50fe1c184464ad73601a4
|
|
4
|
+
data.tar.gz: 2c9dcd2c8be375b2a1525c418ae78836884c84dda8dfbb0b415f86a77a10dec4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d7a2a72bf40838fdb2b08c356c3bdbe62bd52f9a425726e457e50ece570fbad492753482d026b572a30a9a6b1f7a9424c7c453d4a8e8a028c487b98a4b1d920e
|
|
7
|
+
data.tar.gz: 2af8a564330d23d2da659885cef8f6a8c1b19a24939975f7266cb49c24c04f65d3c22cc8b623e576b1fd097b9f05b33ca677aa080c3335e825c473974166f6fa
|
data/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,20 @@ 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.4.0] - 22.10.2025
|
|
16
|
+
|
|
17
|
+
[Diff](https://github.com/espago/rails-on-sorbet/compare/v0.3.6...v0.4.0)
|
|
18
|
+
|
|
19
|
+
### Changes
|
|
20
|
+
- Add `Map::Params` alias for `Map[String | Symbol, untyped]`
|
|
21
|
+
|
|
22
|
+
## [0.3.6] - 21.10.2025
|
|
23
|
+
|
|
24
|
+
[Diff](https://github.com/espago/rails-on-sorbet/compare/v0.3.5...v0.3.6)
|
|
25
|
+
|
|
26
|
+
### Changes
|
|
27
|
+
- Another fix for `TypedRelation` tapioca compiler (type member declarations)
|
|
28
|
+
|
|
15
29
|
## [0.3.5] - 21.10.2025
|
|
16
30
|
|
|
17
31
|
[Diff](https://github.com/espago/rails-on-sorbet/compare/v0.3.4...v0.3.5)
|
data/README.md
CHANGED
|
@@ -85,6 +85,9 @@ m = Map(params) #=> Map[String, untyped]
|
|
|
85
85
|
foo(m) # OK
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
+
There is a `Map::Params` alias for the result of converting `ActionController::Parameters` and
|
|
89
|
+
`ActiveSupport::HashWithIndifferentAccess` to `Map`: `Map[String | Symbol, untyped]`.
|
|
90
|
+
|
|
88
91
|
### TypedRelation
|
|
89
92
|
|
|
90
93
|
Sorbet lacks proper generic handling of `ActiveRecord::Relation`.
|
data/lib/rails/on/sorbet/map.rb
CHANGED
|
@@ -22,34 +22,39 @@ module Tapioca
|
|
|
22
22
|
root.create_path(constant) do |klass|
|
|
23
23
|
private_relation = klass.create_class('PrivateRelation', superclass_name: '::ActiveRecord::Relation')
|
|
24
24
|
private_relation.create_include('::TypedRelation')
|
|
25
|
-
private_relation.create_type_variable('Elem', type: 'type_member',
|
|
25
|
+
private_relation.create_type_variable('Elem', type: 'type_member', fixed: klass.fully_qualified_name)
|
|
26
26
|
|
|
27
27
|
private_relation_group_chain = klass.create_class('PrivateRelationGroupChain',
|
|
28
28
|
superclass_name: 'PrivateRelation',)
|
|
29
29
|
private_relation_group_chain.create_include('::TypedRelation::GroupChain')
|
|
30
|
-
private_relation_group_chain.create_type_variable('Elem', type:
|
|
30
|
+
private_relation_group_chain.create_type_variable('Elem', type: 'type_member',
|
|
31
|
+
fixed: klass.fully_qualified_name,)
|
|
31
32
|
|
|
32
33
|
private_relation_where_chain = klass.create_class('PrivateRelationWhereChain', superclass_name: '::ActiveRecord::QueryMethods::WhereChain')
|
|
33
34
|
private_relation_where_chain.create_include('::TypedRelation::WhereChain')
|
|
34
|
-
private_relation_where_chain.create_type_variable('Elem', type:
|
|
35
|
+
private_relation_where_chain.create_type_variable('Elem', type: 'type_member',
|
|
36
|
+
fixed: klass.fully_qualified_name,)
|
|
35
37
|
|
|
36
38
|
private_association_relation = klass.create_class('PrivateAssociationRelation', superclass_name: '::ActiveRecord::AssociationRelation')
|
|
37
39
|
private_association_relation.create_include('::TypedAssociation::Relation')
|
|
38
|
-
private_association_relation.create_type_variable('Elem', type:
|
|
40
|
+
private_association_relation.create_type_variable('Elem', type: 'type_member',
|
|
41
|
+
fixed: klass.fully_qualified_name,)
|
|
39
42
|
|
|
40
43
|
private_relation_group_chain = klass.create_class('PrivateAssociationRelationGroupChain',
|
|
41
44
|
superclass_name: 'PrivateAssociationRelation',)
|
|
42
45
|
private_relation_group_chain.create_include('::TypedAssociation::Relation::GroupChain')
|
|
43
|
-
private_relation_group_chain.create_type_variable('Elem', type:
|
|
46
|
+
private_relation_group_chain.create_type_variable('Elem', type: 'type_member',
|
|
47
|
+
fixed: klass.fully_qualified_name,)
|
|
44
48
|
|
|
45
49
|
private_relation_where_chain = klass.create_class('PrivateAssociationRelationWhereChain',
|
|
46
50
|
superclass_name: '::ActiveRecord::QueryMethods::WhereChain',)
|
|
47
51
|
private_relation_where_chain.create_include('::TypedAssociation::Relation::WhereChain')
|
|
48
|
-
private_relation_where_chain.create_type_variable('Elem', type:
|
|
52
|
+
private_relation_where_chain.create_type_variable('Elem', type: 'type_member',
|
|
53
|
+
fixed: klass.fully_qualified_name,)
|
|
49
54
|
|
|
50
55
|
private_collection_proxy = klass.create_class('PrivateCollectionProxy', superclass_name: '::ActiveRecord::Associations::CollectionProxy')
|
|
51
56
|
private_collection_proxy.create_include('::TypedAssociation::CollectionProxy')
|
|
52
|
-
private_collection_proxy.create_type_variable('Elem', type: 'type_member',
|
|
57
|
+
private_collection_proxy.create_type_variable('Elem', type: 'type_member', fixed: klass.fully_qualified_name)
|
|
53
58
|
end
|
|
54
59
|
end
|
|
55
60
|
|
|
@@ -21,18 +21,18 @@ module Tapioca
|
|
|
21
21
|
def decorate
|
|
22
22
|
root.create_path(constant) do |klass|
|
|
23
23
|
constant._sorbet_serializer_definitions.sort.each do |name, definition|
|
|
24
|
-
return_type = definition.return_type || definition.coder.try(:return_type) || T.untyped
|
|
24
|
+
return_type = definition.return_type || definition.coder.try(:return_type) || T.untyped
|
|
25
25
|
setter_type = definition.setter_type || definition.coder.try(:setter_type) || return_type
|
|
26
26
|
|
|
27
27
|
return_type_string =
|
|
28
|
-
if return_type == T.unsafe(T.untyped)
|
|
28
|
+
if return_type == T.unsafe(T.untyped)
|
|
29
29
|
return_type.to_s
|
|
30
30
|
else
|
|
31
31
|
"T.nilable(#{return_type})"
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
setter_type_string =
|
|
35
|
-
if setter_type == T.unsafe(T.untyped)
|
|
35
|
+
if setter_type == T.unsafe(T.untyped)
|
|
36
36
|
setter_type.to_s
|
|
37
37
|
else
|
|
38
38
|
"T.nilable(#{setter_type})"
|
data/rbi/map.rbi
CHANGED
|
@@ -36,6 +36,8 @@ def Map(val); end
|
|
|
36
36
|
module Map
|
|
37
37
|
extend T::Generic
|
|
38
38
|
|
|
39
|
+
Params = T.type_alias { Map[T.any(String, Symbol), T.untyped] }
|
|
40
|
+
|
|
39
41
|
# Returns a new array populated with the keys from this hash. See also
|
|
40
42
|
# [`Hash#values`](https://docs.ruby-lang.org/en/2.7.0/Hash.html#method-i-values).
|
|
41
43
|
#
|