rails-on-sorbet 0.3.3 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d255de247b08a136edde26f15049767590f2e303a78e2551df4ef8998ab84512
4
- data.tar.gz: 1d6c912134b2345bd3d6e537b99ab1d89f68f6b6c1ad60f9ea9556a8c025ff3f
3
+ metadata.gz: f489d9f4fc449469fc2c648b63cce27cf7f6765cf119003037567414d8d82554
4
+ data.tar.gz: 16383eef9597808df2fe6e1b044ded34c3a3d1cbfcb26f0b029a30e0195171d1
5
5
  SHA512:
6
- metadata.gz: 7bb596b03ee49d914a6d555eb646b1074357ea2368d24b2dd5a424ce3265de740ab44cbbd7191095cb39622e6991b77e6affa21762a3f5dad6dba078778fea27
7
- data.tar.gz: da155d5a8360f016a854a2d9f9ff9b2ee28b60a83f397d6593773730ff4186ecd4af5ed39ca5966f00317862e95235f4479c6ce062ba41cbde709503560ae178
6
+ metadata.gz: 3ad359e0b378b16ab174854a6a8d552d17b17eb82702c92e4fb06fb6919e42bc543141832c9d91b8be3faa9aa6dcd081e01060484fe4ffb80731d2542730431a
7
+ data.tar.gz: 3319c64c51f3002bed9d4016aef5c9d4d1216e508212b2eeee6d4190ee792aedbf470cc2caca698eb3dac232ded938fda41452d45a3076528ce98a73ee4b7bd5
data/CHANGELOG.md CHANGED
@@ -12,6 +12,14 @@ 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
+
15
23
  ## [0.3.3] - 20.10.2025
16
24
 
17
25
  [Diff](https://github.com/espago/rails-on-sorbet/compare/v0.3.2...v0.3.3)
@@ -6,6 +6,9 @@ require 'active_support'
6
6
 
7
7
  module Map
8
8
  extend T::Generic
9
+
10
+ # Map type for API params.
11
+ Params = T.type_alias { Map[T.any(String, Symbol), T.untyped] }
9
12
  end
10
13
 
11
14
  def Map(val) = val # rubocop:disable Style/TopLevelMethodDefinition,Naming/MethodName
@@ -3,7 +3,7 @@
3
3
  module Rails
4
4
  module On
5
5
  module Sorbet
6
- VERSION = '0.3.3'
6
+ VERSION = '0.3.4'
7
7
  end
8
8
  end
9
9
  end
@@ -16,3 +16,4 @@ require_relative 'sorbet/alias_association'
16
16
  require_relative 'sorbet/current_attributes'
17
17
  require_relative 'sorbet/map'
18
18
  require_relative 'sorbet/timelike'
19
+ require_relative 'sorbet/typed_relation'
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]
@@ -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,6 +886,8 @@ 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
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.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mateusz Drewniak