tapioca 0.17.5 → 0.17.6

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: 302108d7d02504d88d18e3b0ae4832e2fd6c891e83f6428d69d5c4f6773a3a73
4
- data.tar.gz: 646642051b0b9d8736ad30e45d0b1bcfbe82f92b980f0909c45dc7f2337e0ce1
3
+ metadata.gz: dcd84d6187e59dc5b8e2a824d4e9e82182c242710a030fec89393e2c10f4419c
4
+ data.tar.gz: 4e92febe4971b06ac111faa2a544fc404a3b6f718734ac0c06cec97ee631e24e
5
5
  SHA512:
6
- metadata.gz: c6a75f400e82b9f311f0f53713a843a94a3e444a6a52b09d83abd818226a058ec78f02e43b193e864fc90f895ecad0425e7b9d160aaa7c4681b354392a7ad594
7
- data.tar.gz: 831256628c364563d69fe8d742f9fe0a973e12275bdbb5498a6af83c664036aa199ec0a94bf9ba527d3165723bf17aa5852e9eb2b993ccc0ed7439ef0f663a68
6
+ metadata.gz: b4a8b2f9f6b3b69bd3241d5a0503cbf1866288e9dc92c821d410e031bcd91fcf801e003dd54036a1cd6552708d997f0ffb8c989eb5f033758412dca85c7d358e
7
+ data.tar.gz: 05101b64f9d9dab404aea76bf51c9966626efaf024ac31a07a181cdcc9cc276e6175f1e0824c8e4724b0795c36130adec8509d960b40eba39b97533fa89dba0c
@@ -116,7 +116,7 @@ module Tapioca
116
116
  mod.create_method(
117
117
  "build_#{role}",
118
118
  parameters: [create_rest_param("args", type: "T.untyped")],
119
- return_type: "T.any(#{types.join(", ")})",
119
+ return_type: types.size == 1 ? types.first : "T.any(#{types.join(", ")})",
120
120
  )
121
121
  end
122
122
 
@@ -836,7 +836,15 @@ module Tapioca
836
836
  end
837
837
  end
838
838
  when :ids
839
- create_common_method("ids", return_type: "Array")
839
+ if constant.table_exists?
840
+ primary_key_type = constant.type_for_attribute(constant.primary_key)
841
+ type = Tapioca::Dsl::Helpers::ActiveModelTypeHelper.type_for(primary_key_type)
842
+ type = RBIHelper.as_non_nilable_type(type)
843
+ create_common_method("ids", return_type: "T::Array[#{type}]")
844
+ else
845
+ create_common_method("ids", return_type: "Array")
846
+ end
847
+
840
848
  when :pick, :pluck
841
849
  create_common_method(
842
850
  method_name,
@@ -43,7 +43,7 @@ Module.include(T::Sig)
43
43
  # Trigger the source transformation for each Ruby file being loaded.
44
44
  RequireHooks.source_transform(patterns: ["**/*.rb"]) do |path, source|
45
45
  # The source is most likely nil since no `source_transform` hook was triggered before this one.
46
- source ||= File.read(path)
46
+ source ||= File.read(path, encoding: "UTF-8")
47
47
 
48
48
  # For performance reasons, we only rewrite files that use Sorbet.
49
49
  if source =~ /^\s*#\s*typed: (ignore|false|true|strict|strong|__STDLIB_INTERNAL)/
@@ -16,7 +16,7 @@ module T
16
16
  def qualified_name_of(constant)
17
17
  name = NAME_METHOD.bind_call(constant)
18
18
  name = nil if name&.start_with?("#<")
19
- return if name.nil?
19
+ return "::T.untyped" if name.nil?
20
20
 
21
21
  if name.start_with?("::")
22
22
  name
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Tapioca
5
- VERSION = "0.17.5"
5
+ VERSION = "0.17.6"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tapioca
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.5
4
+ version: 0.17.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ufuk Kayserilioglu