alchemrest 3.2.3 → 3.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.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/Appraisals +12 -0
  3. data/Gemfile.lock +33 -33
  4. data/alchemrest.gemspec +1 -1
  5. data/gemfiles/faraday_2.gemfile.lock +4 -4
  6. data/gemfiles/faraday_2_rails_8_1.gemfile +9 -0
  7. data/gemfiles/faraday_2_rails_8_1.gemfile.lock +365 -0
  8. data/gemfiles/rails_7_2.gemfile.lock +4 -4
  9. data/gemfiles/rails_8_0.gemfile.lock +4 -4
  10. data/gemfiles/rails_8_1.gemfile +9 -0
  11. data/gemfiles/rails_8_1.gemfile.lock +387 -0
  12. data/lib/alchemrest/request_definition.rb +1 -1
  13. data/lib/alchemrest/version.rb +1 -1
  14. data/lib/tapioca/dsl/compilers/alchemrest_root.rb +79 -7
  15. data/sorbet/rbi/gems/{actionpack@8.0.4.1.rbi → actionpack@8.1.4.1.rbi} +2356 -1884
  16. data/sorbet/rbi/gems/{actionview@8.0.4.1.rbi → actionview@8.1.4.1.rbi} +1197 -989
  17. data/sorbet/rbi/gems/{activemodel@8.0.4.1.rbi → activemodel@8.1.4.1.rbi} +416 -274
  18. data/sorbet/rbi/gems/{activesupport@8.0.4.1.rbi → activesupport@8.1.4.1.rbi} +1677 -1153
  19. data/sorbet/rbi/gems/{crass@1.0.6.rbi → crass@1.0.7.rbi} +63 -57
  20. data/sorbet/rbi/gems/json@2.19.9.rbi +335 -0
  21. data/sorbet/rbi/gems/{loofah@2.24.0.rbi → loofah@2.25.3.rbi} +127 -83
  22. data/sorbet/rbi/gems/{nokogiri@1.19.4.rbi → nokogiri@1.19.7.rbi} +249 -212
  23. data/sorbet/rbi/gems/{rack@3.1.21.rbi → rack@3.1.23.rbi} +86 -83
  24. data/sorbet/rbi/gems/{rails-html-sanitizer@1.6.2.rbi → rails-html-sanitizer@1.7.2.rbi} +122 -110
  25. data/sorbet/rbi/gems/{railties@8.0.4.1.rbi → railties@8.1.4.1.rbi} +449 -328
  26. data/sorbet/rbi/gems/{yard@0.9.42.rbi → yard@0.9.44.rbi} +246 -195
  27. data/sorbet/rbi/shims/json.rbi +5 -0
  28. metadata +29 -21
  29. data/sorbet/rbi/gems/json@2.9.1.rbi +0 -282
@@ -0,0 +1,387 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ alchemrest (3.4.0)
5
+ activerecord (>= 7.2, < 8.2)
6
+ activesupport (>= 7.2, < 8.2)
7
+ circuitbox (~> 2.0.0)
8
+ faraday (>= 1.10, < 3.0)
9
+ memosa (>= 0.8.2)
10
+ money (>= 6.0)
11
+ morpher (>= 0.4.1)
12
+ multi_json (~> 1.0)
13
+ mustermann-contrib (>= 1.0)
14
+ railties (>= 7.2, < 8.2)
15
+ sentry-ruby
16
+ sorbet-runtime (>= 0.5.0)
17
+
18
+ GEM
19
+ remote: https://rubygems.org/
20
+ specs:
21
+ abstract_type (0.0.7)
22
+ actionpack (8.1.4.1)
23
+ actionview (= 8.1.4.1)
24
+ activesupport (= 8.1.4.1)
25
+ nokogiri (>= 1.8.5)
26
+ rack (>= 2.2.4)
27
+ rack-session (>= 1.0.1)
28
+ rack-test (>= 0.6.3)
29
+ rails-dom-testing (~> 2.2)
30
+ rails-html-sanitizer (~> 1.6)
31
+ useragent (~> 0.16)
32
+ actionview (8.1.4.1)
33
+ activesupport (= 8.1.4.1)
34
+ builder (~> 3.1)
35
+ erubi (~> 1.11)
36
+ rails-dom-testing (~> 2.2)
37
+ rails-html-sanitizer (~> 1.6, >= 1.7.2)
38
+ activemodel (8.1.4.1)
39
+ activesupport (= 8.1.4.1)
40
+ activerecord (8.1.4.1)
41
+ activemodel (= 8.1.4.1)
42
+ activesupport (= 8.1.4.1)
43
+ timeout (>= 0.4.0)
44
+ activesupport (8.1.4.1)
45
+ base64
46
+ bigdecimal
47
+ concurrent-ruby (~> 1.0, >= 1.3.1)
48
+ connection_pool (>= 2.2.5)
49
+ drb
50
+ i18n (>= 1.6, < 2)
51
+ json
52
+ logger (>= 1.4.2)
53
+ minitest (>= 5.1)
54
+ securerandom (>= 0.3)
55
+ tzinfo (~> 2.0, >= 2.0.5)
56
+ uri (>= 0.13.1)
57
+ adamantium (0.2.0)
58
+ ice_nine (~> 0.11.0)
59
+ memoizable (~> 0.4.0)
60
+ addressable (2.8.7)
61
+ public_suffix (>= 2.0.2, < 7.0)
62
+ anima (0.3.2)
63
+ abstract_type (~> 0.0.7)
64
+ adamantium (~> 0.2)
65
+ equalizer (~> 0.0.11)
66
+ appraisal (2.5.0)
67
+ bundler
68
+ rake
69
+ thor (>= 0.14.0)
70
+ ast (2.4.2)
71
+ base64 (0.2.0)
72
+ benchmark (0.4.0)
73
+ betterlint (1.18.0)
74
+ rubocop (~> 1.71)
75
+ rubocop-graphql (~> 1.5)
76
+ rubocop-performance (~> 1.23)
77
+ rubocop-rails (~> 2.29)
78
+ rubocop-rake (~> 0.6)
79
+ rubocop-rspec (~> 2.29)
80
+ bigdecimal (3.1.9)
81
+ builder (3.3.0)
82
+ circuitbox (2.0.0)
83
+ coderay (1.1.3)
84
+ combustion (1.5.0)
85
+ activesupport (>= 3.0.0)
86
+ railties (>= 3.0.0)
87
+ thor (>= 0.14.6)
88
+ concord (0.1.6)
89
+ adamantium (~> 0.2.0)
90
+ equalizer (~> 0.0.9)
91
+ concurrent-ruby (1.3.5)
92
+ connection_pool (2.5.0)
93
+ crack (1.0.0)
94
+ bigdecimal
95
+ rexml
96
+ crass (1.0.6)
97
+ date (3.4.1)
98
+ diff-lcs (1.6.2)
99
+ drb (2.2.1)
100
+ equalizer (0.0.11)
101
+ erubi (1.13.1)
102
+ factory_bot (6.5.0)
103
+ activesupport (>= 5.0.0)
104
+ faraday (1.10.4)
105
+ faraday-em_http (~> 1.0)
106
+ faraday-em_synchrony (~> 1.0)
107
+ faraday-excon (~> 1.1)
108
+ faraday-httpclient (~> 1.0)
109
+ faraday-multipart (~> 1.0)
110
+ faraday-net_http (~> 1.0)
111
+ faraday-net_http_persistent (~> 1.0)
112
+ faraday-patron (~> 1.0)
113
+ faraday-rack (~> 1.0)
114
+ faraday-retry (~> 1.0)
115
+ ruby2_keywords (>= 0.0.4)
116
+ faraday-em_http (1.0.0)
117
+ faraday-em_synchrony (1.0.0)
118
+ faraday-excon (1.1.0)
119
+ faraday-httpclient (1.0.1)
120
+ faraday-multipart (1.1.0)
121
+ multipart-post (~> 2.0)
122
+ faraday-net_http (1.0.2)
123
+ faraday-net_http_persistent (1.2.0)
124
+ faraday-patron (1.0.0)
125
+ faraday-rack (1.0.0)
126
+ faraday-retry (1.0.3)
127
+ hansi (0.2.1)
128
+ hashdiff (1.1.2)
129
+ i18n (1.14.6)
130
+ concurrent-ruby (~> 1.0)
131
+ ice_nine (0.11.2)
132
+ io-console (0.8.0)
133
+ irb (1.15.2)
134
+ pp (>= 0.6.0)
135
+ rdoc (>= 4.0.0)
136
+ reline (>= 0.4.2)
137
+ json (2.9.1)
138
+ language_server-protocol (3.17.0.3)
139
+ logger (1.6.5)
140
+ loofah (2.25.3)
141
+ crass (~> 1.0.2)
142
+ nokogiri (>= 1.19.5)
143
+ memoizable (0.4.2)
144
+ thread_safe (~> 0.3, >= 0.3.1)
145
+ memosa (0.8.2)
146
+ method_source (1.1.0)
147
+ minitest (5.25.4)
148
+ moneta (1.6.0)
149
+ money (6.19.0)
150
+ i18n (>= 0.6.4, <= 2)
151
+ morpher (0.4.2)
152
+ abstract_type (~> 0.0.7)
153
+ adamantium (~> 0.2.0)
154
+ anima (~> 0.3.0)
155
+ concord (~> 0.1.5)
156
+ equalizer (~> 0.0.9)
157
+ mprelude (~> 0.1.0)
158
+ procto (~> 0.0.2)
159
+ mprelude (0.1.0)
160
+ abstract_type (~> 0.0.7)
161
+ adamantium (~> 0.2.0)
162
+ concord (~> 0.1.5)
163
+ equalizer (~> 0.0.9)
164
+ ice_nine (~> 0.11.1)
165
+ procto (~> 0.0.2)
166
+ multi_json (1.15.0)
167
+ multipart-post (2.4.1)
168
+ mustermann (3.0.3)
169
+ ruby2_keywords (~> 0.0.1)
170
+ mustermann-contrib (3.0.3)
171
+ hansi (~> 0.2.0)
172
+ mustermann (= 3.0.3)
173
+ mutant (0.13.4)
174
+ diff-lcs (~> 1.3)
175
+ irb (~> 1.15.2)
176
+ parser (~> 3.3.0)
177
+ regexp_parser (~> 2.10)
178
+ sorbet-runtime (~> 0.5.0)
179
+ unparser (~> 0.8.0)
180
+ mutant-rspec (0.13.4)
181
+ mutant (= 0.13.4)
182
+ rspec-core (>= 3.8.0, < 4.0.0)
183
+ netrc (0.11.0)
184
+ nokogiri (1.19.7-aarch64-linux-gnu)
185
+ racc (~> 1.4)
186
+ nokogiri (1.19.7-aarch64-linux-musl)
187
+ racc (~> 1.4)
188
+ nokogiri (1.19.7-arm64-darwin)
189
+ racc (~> 1.4)
190
+ nokogiri (1.19.7-x86_64-darwin)
191
+ racc (~> 1.4)
192
+ nokogiri (1.19.7-x86_64-linux-gnu)
193
+ racc (~> 1.4)
194
+ nokogiri (1.19.7-x86_64-linux-musl)
195
+ racc (~> 1.4)
196
+ parallel (1.26.3)
197
+ parser (3.3.7.0)
198
+ ast (~> 2.4.1)
199
+ racc
200
+ pg (1.5.9)
201
+ pp (0.6.2)
202
+ prettyprint
203
+ prettyprint (0.2.0)
204
+ prism (1.5.1)
205
+ procto (0.0.3)
206
+ pry (0.15.2)
207
+ coderay (~> 1.1)
208
+ method_source (~> 1.0)
209
+ psych (5.2.3)
210
+ date
211
+ stringio
212
+ public_suffix (6.0.1)
213
+ racc (1.8.1)
214
+ rack (3.1.14)
215
+ rack-session (2.1.1)
216
+ base64 (>= 0.1.0)
217
+ rack (>= 3.0.0)
218
+ rack-test (2.2.0)
219
+ rack (>= 1.3)
220
+ rackup (2.2.1)
221
+ rack (>= 3)
222
+ rails-dom-testing (2.2.0)
223
+ activesupport (>= 5.0.0)
224
+ minitest
225
+ nokogiri (>= 1.6)
226
+ rails-html-sanitizer (1.7.2)
227
+ loofah (~> 2.25, >= 2.25.3)
228
+ nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
229
+ railties (8.1.4.1)
230
+ actionpack (= 8.1.4.1)
231
+ activesupport (= 8.1.4.1)
232
+ irb (~> 1.13)
233
+ rackup (>= 1.0.0)
234
+ rake (>= 12.2)
235
+ thor (~> 1.0, >= 1.2.2)
236
+ tsort (>= 0.2)
237
+ zeitwerk (~> 2.6)
238
+ rainbow (3.1.1)
239
+ rake (13.2.1)
240
+ rbi (0.2.3)
241
+ prism (~> 1.0)
242
+ sorbet-runtime (>= 0.5.9204)
243
+ rdoc (6.13.1)
244
+ psych (>= 4.0.0)
245
+ regexp_parser (2.11.3)
246
+ reline (0.6.0)
247
+ io-console (~> 0.5)
248
+ rexml (3.4.0)
249
+ rspec (3.13.0)
250
+ rspec-core (~> 3.13.0)
251
+ rspec-expectations (~> 3.13.0)
252
+ rspec-mocks (~> 3.13.0)
253
+ rspec-core (3.13.2)
254
+ rspec-support (~> 3.13.0)
255
+ rspec-expectations (3.13.3)
256
+ diff-lcs (>= 1.2.0, < 2.0)
257
+ rspec-support (~> 3.13.0)
258
+ rspec-mocks (3.13.2)
259
+ diff-lcs (>= 1.2.0, < 2.0)
260
+ rspec-support (~> 3.13.0)
261
+ rspec-support (3.13.2)
262
+ rspec_junit_formatter (0.6.0)
263
+ rspec-core (>= 2, < 4, != 2.12.0)
264
+ rubocop (1.71.1)
265
+ json (~> 2.3)
266
+ language_server-protocol (>= 3.17.0)
267
+ parallel (~> 1.10)
268
+ parser (>= 3.3.0.2)
269
+ rainbow (>= 2.2.2, < 4.0)
270
+ regexp_parser (>= 2.9.3, < 3.0)
271
+ rubocop-ast (>= 1.38.0, < 2.0)
272
+ ruby-progressbar (~> 1.7)
273
+ unicode-display_width (>= 2.4.0, < 4.0)
274
+ rubocop-ast (1.38.0)
275
+ parser (>= 3.3.1.0)
276
+ rubocop-capybara (2.21.0)
277
+ rubocop (~> 1.41)
278
+ rubocop-factory_bot (2.26.1)
279
+ rubocop (~> 1.61)
280
+ rubocop-graphql (1.5.4)
281
+ rubocop (>= 1.50, < 2)
282
+ rubocop-performance (1.23.1)
283
+ rubocop (>= 1.48.1, < 2.0)
284
+ rubocop-ast (>= 1.31.1, < 2.0)
285
+ rubocop-rails (2.29.1)
286
+ activesupport (>= 4.2.0)
287
+ rack (>= 1.1)
288
+ rubocop (>= 1.52.0, < 2.0)
289
+ rubocop-ast (>= 1.31.1, < 2.0)
290
+ rubocop-rake (0.6.0)
291
+ rubocop (~> 1.0)
292
+ rubocop-rspec (2.31.0)
293
+ rubocop (~> 1.40)
294
+ rubocop-capybara (~> 2.17)
295
+ rubocop-factory_bot (~> 2.22)
296
+ rubocop-rspec_rails (~> 2.28)
297
+ rubocop-rspec_rails (2.29.1)
298
+ rubocop (~> 1.61)
299
+ ruby-progressbar (1.13.0)
300
+ ruby2_keywords (0.0.5)
301
+ securerandom (0.4.1)
302
+ sentry-ruby (5.22.1)
303
+ bigdecimal
304
+ concurrent-ruby (~> 1.0, >= 1.0.2)
305
+ sorbet (0.5.11763)
306
+ sorbet-static (= 0.5.11763)
307
+ sorbet-runtime (0.5.11763)
308
+ sorbet-static (0.5.11763-aarch64-linux)
309
+ sorbet-static (0.5.11763-universal-darwin)
310
+ sorbet-static (0.5.11763-x86_64-linux)
311
+ sorbet-static-and-runtime (0.5.11763)
312
+ sorbet (= 0.5.11763)
313
+ sorbet-runtime (= 0.5.11763)
314
+ spoom (1.5.1)
315
+ erubi (>= 1.10.0)
316
+ prism (>= 0.28.0)
317
+ sorbet-static-and-runtime (>= 0.5.10187)
318
+ thor (>= 0.19.2)
319
+ stringio (3.1.2)
320
+ tapioca (0.16.8)
321
+ benchmark
322
+ bundler (>= 2.2.25)
323
+ netrc (>= 0.11.0)
324
+ parallel (>= 1.21.0)
325
+ rbi (~> 0.2)
326
+ sorbet-static-and-runtime (>= 0.5.11087)
327
+ spoom (>= 1.2.0)
328
+ thor (>= 1.2.0)
329
+ yard-sorbet
330
+ thor (1.3.2)
331
+ thread_safe (0.3.6)
332
+ timecop (0.9.10)
333
+ timeout (0.4.3)
334
+ tsort (0.2.0)
335
+ tzinfo (2.0.6)
336
+ concurrent-ruby (~> 1.0)
337
+ unicode-display_width (2.6.0)
338
+ unparser (0.8.0)
339
+ diff-lcs (~> 1.6)
340
+ parser (>= 3.3.0)
341
+ prism (>= 1.4)
342
+ uri (1.0.3)
343
+ useragent (0.16.11)
344
+ webmock (3.24.0)
345
+ addressable (>= 2.8.0)
346
+ crack (>= 0.3.2)
347
+ hashdiff (>= 0.4.0, < 2.0.0)
348
+ yard (0.9.37)
349
+ yard-sorbet (0.9.0)
350
+ sorbet-runtime
351
+ yard
352
+ zeitwerk (2.7.1)
353
+
354
+ PLATFORMS
355
+ aarch64-linux-gnu
356
+ aarch64-linux-musl
357
+ arm64-darwin
358
+ x86_64-darwin
359
+ x86_64-linux-gnu
360
+ x86_64-linux-musl
361
+
362
+ DEPENDENCIES
363
+ activemodel
364
+ activerecord (~> 8.1.0)
365
+ activesupport (~> 8.1.0)
366
+ alchemrest!
367
+ appraisal
368
+ betterlint
369
+ combustion
370
+ factory_bot
371
+ faraday (~> 1.10)
372
+ moneta
373
+ mutant-rspec (~> 0.13.4)
374
+ pg
375
+ pry
376
+ rake (~> 13.0)
377
+ rspec (~> 3.0)
378
+ rspec_junit_formatter
379
+ rubocop
380
+ rubocop-rspec
381
+ sorbet
382
+ tapioca (>= 0.16.6)
383
+ timecop
384
+ webmock
385
+
386
+ BUNDLED WITH
387
+ 2.6.9
@@ -5,7 +5,7 @@ module Alchemrest
5
5
  # we want to create, and block that can extract default parameters from an Alchemrest::Root. When we want to build an
6
6
  # instance of the request, call `build_request` and pass in the root as context, with any additional parameters.
7
7
  class RequestDefinition
8
- attr_reader :name
8
+ attr_reader :name, :request_class, :builder_block
9
9
 
10
10
  def initialize(name, request_class, &block)
11
11
  @name = name
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Alchemrest
4
- VERSION = "3.2.3"
4
+ VERSION = "3.4.0"
5
5
  end
@@ -3,28 +3,44 @@
3
3
 
4
4
  require 'active_support/core_ext/enumerable'
5
5
  require 'alchemrest'
6
+ require 'prism'
6
7
 
7
8
  module Tapioca
8
9
  module Dsl
9
10
  module Compilers
10
11
  # This compiler generates RBI files for classes that inherit from `Alchemrest::Root`.
11
12
  #
12
- # For example, given the following class:
13
+ # For example, given the following classes:
14
+ #
15
+ # class UpdateProfile < Alchemrest::Request
16
+ # extend T::Sig
17
+ #
18
+ # sig { params(id: Integer, name: String).void }
19
+ # def initialize(id:, name:)
20
+ # ...
21
+ # end
22
+ #
23
+ # returns Profile
24
+ # end
13
25
  #
14
26
  # class Root < Alchemrest::Root
15
- # define_request :get_profile, Requests::GetProfile
27
+ # define_request :update_profile, UpdateProfile do |request|
28
+ # request.defaults = { id: }
29
+ # end
16
30
  # end
17
31
  #
18
32
  # This compiler will generate an RBI file `root.rbi` with the following content:
19
33
  #
20
- # sig { params(params: T::Hash[Symbol, T.untyped]).returns(::Alchemrest::Result[::Profile]) }
21
- # def get_profile(params = {}); end
34
+ # sig { params(name: ::String, id: ::Integer).returns(::Alchemrest::Result[::Profile]) }
35
+ # def update_profile(name:, id: T.unsafe(nil)); end
22
36
  #
23
37
  class AlchemrestRoot < Tapioca::Dsl::Compiler
24
38
  extend T::Sig
25
39
 
26
40
  ConstantType = type_member { { upper: T.class_of(Alchemrest::Root) } }
27
41
 
42
+ KEYWORD_PARAM_TYPES = [RBI::KwParam, RBI::KwOptParam, RBI::KwRestParam].freeze
43
+
28
44
  sig { override.returns(T::Enumerable[Module]) }
29
45
  def self.gather_constants
30
46
  descendants_of(Alchemrest::Root)
@@ -36,7 +52,7 @@ module Tapioca
36
52
  constant.request_definitions.each do |name, definition|
37
53
  rbi.create_method(
38
54
  name.to_s,
39
- parameters: [create_opt_param('params', type: 'T::Hash[Symbol, T.untyped]', default: '{}')],
55
+ parameters: parameters_for(definition),
40
56
  return_type: return_type_for(definition),
41
57
  )
42
58
  end
@@ -45,6 +61,63 @@ module Tapioca
45
61
 
46
62
  private
47
63
 
64
+ sig { params(definition: Alchemrest::RequestDefinition).returns(T::Array[RBI::TypedParam]) }
65
+ def parameters_for(definition)
66
+ parameters = compile_method_parameters_to_rbi(definition.request_class.instance_method(:initialize))
67
+
68
+ if parameters.all? { |typed_param| KEYWORD_PARAM_TYPES.include?(typed_param.param.class) }
69
+ optional_keys = defaulted_keys_for(definition) || parameters.map { |typed_param| typed_param.param.name }
70
+ with_optional_keys(parameters, optional_keys)
71
+ else
72
+ [create_opt_param('params', type: 'T::Hash[Symbol, T.untyped]', default: '{}')]
73
+ end
74
+ end
75
+
76
+ sig { params(parameters: T::Array[RBI::TypedParam], optional_keys: T::Array[String]).returns(T::Array[RBI::TypedParam]) }
77
+ def with_optional_keys(parameters, optional_keys)
78
+ parameters = parameters.map do |typed_param|
79
+ param = typed_param.param
80
+
81
+ if param.is_a?(RBI::KwParam) && optional_keys.include?(param.name)
82
+ create_kw_opt_param(param.name, type: typed_param.type, default: 'T.unsafe(nil)')
83
+ else
84
+ typed_param
85
+ end
86
+ end
87
+
88
+ required, optional = parameters.partition { |typed_param| typed_param.param.is_a?(RBI::KwParam) }
89
+ required + optional
90
+ end
91
+
92
+ sig { params(definition: Alchemrest::RequestDefinition).returns(T.nilable(T::Array[String])) }
93
+ def defaulted_keys_for(definition)
94
+ if definition.builder_block
95
+ literal_defaults_keys(block_node_for(definition.builder_block))
96
+ else
97
+ []
98
+ end
99
+ end
100
+
101
+ sig { params(block_node: T.nilable(Prism::Node)).returns(T.nilable(T::Array[String])) }
102
+ def literal_defaults_keys(block_node)
103
+ case block_node
104
+ in { body: { body: [Prism::CallNode[name: :defaults=, arguments: { arguments: [Prism::HashNode[elements:]] }]] } }
105
+ symbol_keys = elements.grep(Prism::AssocNode).map(&:key).grep(Prism::SymbolNode)
106
+ symbol_keys.map(&:unescaped) if symbol_keys.size == elements.size
107
+ else
108
+ nil
109
+ end
110
+ end
111
+
112
+ sig { params(builder_block: Proc).returns(T.nilable(Prism::Node)) }
113
+ def block_node_for(builder_block)
114
+ file, line = builder_block.source_location
115
+
116
+ if file && File.exist?(file)
117
+ Prism.parse_file(file).value.breadth_first_search { |node| node.is_a?(Prism::BlockNode) && node.location.start_line == line }
118
+ end
119
+ end
120
+
48
121
  sig { params(definition: Alchemrest::RequestDefinition).returns(String) }
49
122
  def return_type_for(definition)
50
123
  transform = extract_transform(definition)
@@ -58,8 +131,7 @@ module Tapioca
58
131
 
59
132
  sig { params(definition: Alchemrest::RequestDefinition).returns(T.nilable(Alchemrest::Transforms::Typed)) }
60
133
  def extract_transform(definition)
61
- request_class = definition.instance_variable_get(:@request_class)
62
- returns_modules = request_class.ancestors.grep(Alchemrest::Request::Returns)
134
+ returns_modules = definition.request_class.ancestors.grep(Alchemrest::Request::Returns)
63
135
  returns_modules.sole.domain_type.const_get(:TRANSFORM) if returns_modules.one?
64
136
  end
65
137
  end