rails-on-sorbet 0.2.2 → 0.2.3

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.
data/rbi/map.rbi ADDED
@@ -0,0 +1,933 @@
1
+ # typed: false
2
+
3
+ #: [K, V] (Hash[K, V]) -> Map[K, V]
4
+ #: (ActionController::Parameters | ActiveSupport::HashWithIndifferentAccess) -> Map[String | Symbol, untyped]
5
+ def Map(val); end
6
+
7
+ # @requires_ancestor: Object
8
+ # @abstract
9
+ #: [out K, out V]
10
+ module Map
11
+ # Returns a new array populated with the keys from this hash. See also
12
+ # [`Hash#values`](https://docs.ruby-lang.org/en/2.7.0/Hash.html#method-i-values).
13
+ #
14
+ # ```ruby
15
+ # h = { "a" => 100, "b" => 200, "c" => 300, "d" => 400 }
16
+ # h.keys #=> ["a", "b", "c", "d"]
17
+ # ```
18
+ sig {abstract.returns(T::Array[K])}
19
+ def keys(); end
20
+
21
+ # Returns `true` if *hsh* contains no key-value pairs.
22
+ #
23
+ # ```ruby
24
+ # {}.empty? #=> true
25
+ # ```
26
+ sig {abstract.returns(T::Boolean)}
27
+ def empty?(); end
28
+
29
+ sig { abstract.params(object: BasicObject).returns(T::Boolean) }
30
+ def exclude?(object); end
31
+
32
+ # Returns `true` if the given key is present in *hsh*.
33
+ #
34
+ # ```ruby
35
+ # h = { "a" => 100, "b" => 200 }
36
+ # h.has_key?("a") #=> true
37
+ # h.has_key?("z") #=> false
38
+ # ```
39
+ #
40
+ # Note that
41
+ # [`include?`](https://docs.ruby-lang.org/en/2.7.0/Hash.html#method-i-include-3F)
42
+ # and
43
+ # [`member?`](https://docs.ruby-lang.org/en/2.7.0/Hash.html#method-i-member-3F)
44
+ # do not test member equality using `==` as do other Enumerables.
45
+ #
46
+ # See also
47
+ # [`Enumerable#include?`](https://docs.ruby-lang.org/en/2.7.0/Enumerable.html#method-i-include-3F)
48
+ sig do
49
+ abstract.params(
50
+ arg0: K,
51
+ )
52
+ .returns(T::Boolean)
53
+ end
54
+ def include?(arg0); end
55
+
56
+ sig { abstract.params(options: T.untyped).returns(T.untyped) }
57
+ def as_json(*options); end
58
+
59
+ # Alias for:
60
+ # [`inspect`](https://docs.ruby-lang.org/en/2.7.0/Hash.html#method-i-inspect)
61
+ sig {abstract.returns(String)}
62
+ def to_s(); end
63
+
64
+ # Calls *block* once for each key in *hsh*, passing the key as a parameter.
65
+ #
66
+ # If no block is given, an enumerator is returned instead.
67
+ #
68
+ # ```ruby
69
+ # h = { "a" => 100, "b" => 200 }
70
+ # h.each_key {|key| puts key }
71
+ # ```
72
+ #
73
+ # *produces:*
74
+ #
75
+ # ```ruby
76
+ # a
77
+ # b
78
+ # ```
79
+ sig do
80
+ abstract.params(
81
+ blk: T.proc.params(arg0: K).returns(BasicObject),
82
+ )
83
+ .returns(T::Hash[K, V])
84
+ end
85
+ sig {abstract.returns(T::Enumerator[K])}
86
+ def each_key(&blk); end
87
+
88
+ # Returns `true` if the given key is present in *hsh*.
89
+ #
90
+ # ```ruby
91
+ # h = { "a" => 100, "b" => 200 }
92
+ # h.has_key?("a") #=> true
93
+ # h.has_key?("z") #=> false
94
+ # ```
95
+ #
96
+ # Note that
97
+ # [`include?`](https://docs.ruby-lang.org/en/2.7.0/Hash.html#method-i-include-3F)
98
+ # and
99
+ # [`member?`](https://docs.ruby-lang.org/en/2.7.0/Hash.html#method-i-member-3F)
100
+ # do not test member equality using `==` as do other Enumerables.
101
+ #
102
+ # See also
103
+ # [`Enumerable#include?`](https://docs.ruby-lang.org/en/2.7.0/Enumerable.html#method-i-include-3F)
104
+ sig do
105
+ abstract.params(
106
+ arg0: K,
107
+ )
108
+ .returns(T::Boolean)
109
+ end
110
+ def has_key?(arg0); end
111
+
112
+ sig do
113
+ abstract.params(
114
+ arg0: K,
115
+ )
116
+ .returns(T::Boolean)
117
+ end
118
+ def key?(arg0); end
119
+
120
+ # Returns `true` if the given key is present in *hsh*.
121
+ #
122
+ # ```ruby
123
+ # h = { "a" => 100, "b" => 200 }
124
+ # h.has_key?("a") #=> true
125
+ # h.has_key?("z") #=> false
126
+ # ```
127
+ #
128
+ # Note that
129
+ # [`include?`](https://docs.ruby-lang.org/en/2.7.0/Hash.html#method-i-include-3F)
130
+ # and
131
+ # [`member?`](https://docs.ruby-lang.org/en/2.7.0/Hash.html#method-i-member-3F)
132
+ # do not test member equality using `==` as do other Enumerables.
133
+ #
134
+ # See also
135
+ # [`Enumerable#include?`](https://docs.ruby-lang.org/en/2.7.0/Enumerable.html#method-i-include-3F)
136
+ sig do
137
+ abstract.params(
138
+ arg0: K,
139
+ )
140
+ .returns(T::Boolean)
141
+ end
142
+ def member?(arg0); end
143
+
144
+ # Equality---Two hashes are equal if they each contain the same number of keys
145
+ # and if each key-value pair is equal to (according to Object#==) the
146
+ # corresponding elements in the other hash.
147
+ #
148
+ # ```ruby
149
+ # h1 = { "a" => 1, "c" => 2 }
150
+ # h2 = { 7 => 35, "c" => 2, "a" => 1 }
151
+ # h3 = { "a" => 1, "c" => 2, 7 => 35 }
152
+ # h4 = { "a" => 1, "d" => 2, "f" => 35 }
153
+ # h1 == h2 #=> false
154
+ # h2 == h3 #=> true
155
+ # h3 == h4 #=> false
156
+ # ```
157
+ #
158
+ # The orders of each hashes are not compared.
159
+ #
160
+ # ```ruby
161
+ # h1 = { "a" => 1, "c" => 2 }
162
+ # h2 = { "c" => 2, "a" => 1 }
163
+ # h1 == h2 #=> true
164
+ # ```
165
+ sig {abstract.params(_: T.untyped).returns(T::Boolean)}
166
+ def ==(_); end
167
+
168
+ sig {abstract.params(_: T.untyped).returns(T::Boolean)}
169
+ def eql?(_); end
170
+
171
+ sig { abstract.returns(Integer) }
172
+ def hash; end
173
+
174
+ # Returns `self`. If called on a subclass of
175
+ # [`Hash`](https://docs.ruby-lang.org/en/2.7.0/Hash.html), converts the
176
+ # receiver to a [`Hash`](https://docs.ruby-lang.org/en/2.7.0/Hash.html)
177
+ # object.
178
+ #
179
+ # If a block is given, the results of the block on each pair of the receiver
180
+ # will be used as pairs.
181
+ sig do
182
+ abstract.type_parameters(:A, :B)
183
+ .params(
184
+ blk: T.proc.params(arg0: K, arg1: V)
185
+ .returns([T.type_parameter(:A), T.type_parameter(:B)])
186
+ )
187
+ .returns(T::Hash[T.type_parameter(:A), T.type_parameter(:B)])
188
+ end
189
+ sig {abstract.returns(T::Hash[K, V])}
190
+ def to_h(&blk); end
191
+
192
+ # Returns `self`. If called on a subclass of
193
+ # [`Hash`](https://docs.ruby-lang.org/en/2.7.0/Hash.html), converts the
194
+ # receiver to a [`Hash`](https://docs.ruby-lang.org/en/2.7.0/Hash.html)
195
+ # object.
196
+ #
197
+ # If a block is given, the results of the block on each pair of the receiver
198
+ # will be used as pairs.
199
+ sig {abstract.returns(T::Hash[K, V])}
200
+ def to_hash(); end
201
+
202
+ # Returns a string representation of the receiver suitable for use as a URL
203
+ # query string:
204
+ #
205
+ # {name: 'David', nationality: 'Danish'}.to_query
206
+ # # => "name=David&nationality=Danish"
207
+ #
208
+ # An optional namespace can be passed to enclose key names:
209
+ #
210
+ # {name: 'David', nationality: 'Danish'}.to_query('user')
211
+ # # => "user%5Bname%5D=David&user%5Bnationality%5D=Danish"
212
+ #
213
+ # The string pairs "key=value" that conform the query string
214
+ # are sorted lexicographically in ascending order.
215
+ #
216
+ # source://activesupport//lib/active_support/core_ext/object/to_query.rb#75
217
+ sig { abstract.params(namespace: T.untyped).returns(String) }
218
+ def to_query(namespace = T.unsafe(nil)); end
219
+
220
+ # Calls *block* once for each key in *hsh*, passing the key-value pair as
221
+ # parameters.
222
+ #
223
+ # If no block is given, an enumerator is returned instead.
224
+ #
225
+ # ```ruby
226
+ # h = { "a" => 100, "b" => 200 }
227
+ # h.each {|key, value| puts "#{key} is #{value}" }
228
+ # ```
229
+ #
230
+ # *produces:*
231
+ #
232
+ # ```ruby
233
+ # a is 100
234
+ # b is 200
235
+ # ```
236
+ sig do
237
+ abstract.params(
238
+ blk: T.proc.params(arg0: K, arg1: V).returns(BasicObject),
239
+ )
240
+ .returns(T::Hash[K, V])
241
+ end
242
+ sig {abstract.returns(T::Enumerator[[K, V]])}
243
+ def each_pair(&blk); end
244
+
245
+ # Calls *block* once for each key in *hsh*, passing the value as a parameter.
246
+ #
247
+ # If no block is given, an enumerator is returned instead.
248
+ #
249
+ # ```ruby
250
+ # h = { "a" => 100, "b" => 200 }
251
+ # h.each_value {|value| puts value }
252
+ # ```
253
+ #
254
+ # *produces:*
255
+ #
256
+ # ```ruby
257
+ # 100
258
+ # 200
259
+ # ```
260
+ sig do
261
+ abstract.params(
262
+ blk: T.proc.params(arg0: V).returns(BasicObject),
263
+ )
264
+ .returns(T::Hash[K, V])
265
+ end
266
+ sig {abstract.returns(T::Enumerator[V])}
267
+ def each_value(&blk); end
268
+
269
+ # Returns a new array populated with the values from *hsh*. See also
270
+ # [`Hash#keys`](https://docs.ruby-lang.org/en/2.7.0/Hash.html#method-i-keys).
271
+ #
272
+ # ```ruby
273
+ # h = { "a" => 100, "b" => 200, "c" => 300 }
274
+ # h.values #=> [100, 200, 300]
275
+ # ```
276
+ sig {abstract.returns(T::Array[V])}
277
+ def values(); end
278
+
279
+ # Element Reference---Retrieves the *value* object corresponding to the *key*
280
+ # object. If not found, returns the default value (see
281
+ # [`Hash::new`](https://docs.ruby-lang.org/en/2.7.0/Hash.html#method-c-new)
282
+ # for details).
283
+ #
284
+ # ```ruby
285
+ # h = { "a" => 100, "b" => 200 }
286
+ # h["a"] #=> 100
287
+ # h["c"] #=> nil
288
+ # ```
289
+ sig do
290
+ abstract.params(
291
+ arg0: K,
292
+ )
293
+ .returns(T.nilable(V))
294
+ end
295
+ def [](arg0); end
296
+
297
+ # ## Element Assignment
298
+ #
299
+ # Associates the value given by `value` with the key given by `key`.
300
+ #
301
+ # ```ruby
302
+ # h = { "a" => 100, "b" => 200 }
303
+ # h["a"] = 9
304
+ # h["c"] = 4
305
+ # h #=> {"a"=>9, "b"=>200, "c"=>4}
306
+ # h.store("d", 42) #=> 42
307
+ # h #=> {"a"=>9, "b"=>200, "c"=>4, "d"=>42}
308
+ # ```
309
+ #
310
+ # `key` should not have its value changed while it is in use as a key (an
311
+ # `unfrozen String` passed as a key will be duplicated and frozen).
312
+ #
313
+ # ```ruby
314
+ # a = "a"
315
+ # b = "b".freeze
316
+ # h = { a => 100, b => 200 }
317
+ # h.key(100).equal? a #=> false
318
+ # h.key(200).equal? b #=> true
319
+ # ```
320
+ sig do
321
+ abstract.params(
322
+ arg0: K,
323
+ arg1: V,
324
+ )
325
+ .returns(V)
326
+ end
327
+ def []=(arg0, arg1); end
328
+
329
+ # Returns a value from the hash for the given key. If the key can't be found,
330
+ # there are several options: With no other arguments, it will raise a
331
+ # [`KeyError`](https://docs.ruby-lang.org/en/2.7.0/KeyError.html) exception;
332
+ # if *default* is given, then that will be returned; if the optional code
333
+ # block is specified, then that will be run and its result returned.
334
+ #
335
+ # ```ruby
336
+ # h = { "a" => 100, "b" => 200 }
337
+ # h.fetch("a") #=> 100
338
+ # h.fetch("z", "go fish") #=> "go fish"
339
+ # h.fetch("z") { |el| "go fish, #{el}"} #=> "go fish, z"
340
+ # ```
341
+ #
342
+ # The following example shows that an exception is raised if the key is not
343
+ # found and a default value is not supplied.
344
+ #
345
+ # ```ruby
346
+ # h = { "a" => 100, "b" => 200 }
347
+ # h.fetch("z")
348
+ # ```
349
+ #
350
+ # *produces:*
351
+ #
352
+ # ```
353
+ # prog.rb:2:in `fetch': key not found (KeyError)
354
+ # from prog.rb:2
355
+ # ```
356
+ sig do
357
+ abstract.params(
358
+ arg0: K,
359
+ )
360
+ .returns(V)
361
+ end
362
+ sig do
363
+ abstract.type_parameters(:X).params(
364
+ arg0: K,
365
+ arg1: T.type_parameter(:X),
366
+ )
367
+ .returns(T.any(V, T.type_parameter(:X)))
368
+ end
369
+ sig do
370
+ abstract.type_parameters(:X).params(
371
+ arg0: K,
372
+ blk: T.proc.params(arg0: K).returns(T.type_parameter(:X)),
373
+ )
374
+ .returns(T.any(V, T.type_parameter(:X)))
375
+ end
376
+ def fetch(arg0, arg1=T.unsafe(nil), &blk); end
377
+
378
+ # Extracts the nested value specified by the sequence of *key* objects by
379
+ # calling `dig` at each step, returning `nil` if any intermediate step is
380
+ # `nil`.
381
+ #
382
+ # ```ruby
383
+ # h = { foo: {bar: {baz: 1}}}
384
+ #
385
+ # h.dig(:foo, :bar, :baz) #=> 1
386
+ # h.dig(:foo, :zot, :xyz) #=> nil
387
+ #
388
+ # g = { foo: [10, 11, 12] }
389
+ # g.dig(:foo, 1) #=> 11
390
+ # g.dig(:foo, 1, 0) #=> TypeError: Integer does not have #dig method
391
+ # g.dig(:foo, :bar) #=> TypeError: no implicit conversion of Symbol into Integer
392
+ # ```
393
+ sig do
394
+ abstract.params(
395
+ key: K,
396
+ rest: T.untyped
397
+ )
398
+ .returns(T.untyped)
399
+ end
400
+ def dig(key, *rest); end
401
+
402
+ # Returns a hash containing only the given keys and their values.
403
+ #
404
+ # ```ruby
405
+ # h = { a: 100, b: 200, c: 300 }
406
+ # h.slice(:a) #=> {:a=>100}
407
+ # h.slice(:b, :c, :d) #=> {:b=>200, :c=>300}
408
+ # ```
409
+ sig do
410
+ abstract.params(
411
+ arg0: K,
412
+ )
413
+ .returns(T::Hash[K, V])
414
+ end
415
+ def slice(*arg0); end
416
+
417
+ # Replaces the hash with only the given keys.
418
+ # Returns a hash containing the removed key/value pairs.
419
+ #
420
+ # hash = { a: 1, b: 2, c: 3, d: 4 }
421
+ # hash.slice!(:a, :b) # => {:c=>3, :d=>4}
422
+ # hash # => {:a=>1, :b=>2}
423
+ #
424
+ # source://activesupport//lib/active_support/core_ext/hash/slice.rb#10
425
+ sig do
426
+ abstract.params(
427
+ keys: K,
428
+ )
429
+ .returns(T::Hash[K, V])
430
+ end
431
+ def slice!(*keys); end
432
+
433
+ # Returns a new Hash excluding entries for the given keys.
434
+ # [`Hash#except`](https://ruby-doc.org/core-3.0.0/Hash.html#method-i-except)
435
+ #
436
+ # ```ruby
437
+ # h = { a: 100, b: 200, c: 300 }
438
+ # h.except(:a) #=> {:b=>200, :c=>300}
439
+ # ```
440
+ sig do
441
+ abstract.params(
442
+ args: K,
443
+ )
444
+ .returns(T::Hash[K, V])
445
+ end
446
+ def except(*args); end
447
+
448
+ # Removes and returns the key/value pairs matching the given keys.
449
+ #
450
+ # hash = { a: 1, b: 2, c: 3, d: 4 }
451
+ # hash.extract!(:a, :b) # => {:a=>1, :b=>2}
452
+ # hash # => {:c=>3, :d=>4}
453
+ #
454
+ # source://activesupport//lib/active_support/core_ext/hash/slice.rb#24
455
+ def extract!(*keys); end
456
+
457
+ # Returns a new hash with the results of running the block once for every
458
+ # value. This method does not change the keys.
459
+ #
460
+ # ```ruby
461
+ # h = { a: 1, b: 2, c: 3 }
462
+ # h.transform_values {|v| v * v + 1 } #=> { a: 2, b: 5, c: 10 }
463
+ # h.transform_values(&:to_s) #=> { a: "1", b: "2", c: "3" }
464
+ # h.transform_values.with_index {|v, i| "#{v}.#{i}" }
465
+ # #=> { a: "1.0", b: "2.1", c: "3.2" }
466
+ # ```
467
+ #
468
+ # If no block is given, an enumerator is returned instead.
469
+ sig do
470
+ abstract.type_parameters(:A).params(
471
+ blk: T.proc.params(arg0: V).returns(T.type_parameter(:A))
472
+ )
473
+ .returns(T::Hash[K, T.type_parameter(:A)])
474
+ end
475
+ sig do
476
+ abstract.returns(T::Enumerator[V])
477
+ end
478
+ def transform_values(&blk); end
479
+
480
+ # Invokes the given block once for each value in *hsh*, replacing it with the
481
+ # new value returned by the block, and then returns *hsh*. This method does
482
+ # not change the keys.
483
+ #
484
+ # ```ruby
485
+ # h = { a: 1, b: 2, c: 3 }
486
+ # h.transform_values! {|v| v * v + 1 } #=> { a: 2, b: 5, c: 10 }
487
+ # h.transform_values!(&:to_s) #=> { a: "2", b: "5", c: "10" }
488
+ # h.transform_values!.with_index {|v, i| "#{v}.#{i}" }
489
+ # #=> { a: "2.0", b: "5.1", c: "10.2" }
490
+ # ```
491
+ #
492
+ # If no block is given, an enumerator is returned instead.
493
+ sig do
494
+ abstract.type_parameters(:A).params(
495
+ blk: T.proc.params(arg0: V).returns(T.type_parameter(:A))
496
+ )
497
+ .returns(T::Hash[K, T.type_parameter(:A)])
498
+ end
499
+ sig do
500
+ abstract.returns(T::Enumerator[V])
501
+ end
502
+ def transform_values!(&blk); end
503
+
504
+ # Returns a new hash with the results of running the block once for every key.
505
+ #
506
+ # An optional hash argument can be provided to map keys to new keys. Any key
507
+ # not given will be mapped using the provided block, or remain the same if no
508
+ # block is given.
509
+ #
510
+ # This method does not change the values.
511
+ #
512
+ # ```ruby
513
+ # h = { a: 1, b: 2, c: 3 }
514
+ # h.transform_keys {|k| k.to_s } #=> { "a" => 1, "b" => 2, "c" => 3 }
515
+ # h.transform_keys(&:to_s) #=> { "a" => 1, "b" => 2, "c" => 3 }
516
+ # h.transform_keys.with_index {|k, i| "#{k}.#{i}" }
517
+ # #=> { "a.0" => 1, "b.1" => 2, "c.2" => 3 }
518
+ # h.transform_keys({ a: "a", b: "b" }) #=> { "a" => 1, "b" => 2, c: 3 }
519
+ # ```
520
+ #
521
+ # If no block is given, an enumerator is returned instead.
522
+ sig do
523
+ abstract.type_parameters(:A).params(
524
+ hash2: T.nilable(T::Hash[T.type_parameter(:A), V]),
525
+ blk: T.proc.params(arg0: K).returns(T.type_parameter(:A))
526
+ )
527
+ .returns(T::Hash[T.type_parameter(:A), V])
528
+ end
529
+ sig do
530
+ abstract.type_parameters(:A).params(
531
+ hash2: T::Hash[T.type_parameter(:A), V],
532
+ )
533
+ .returns(T::Hash[T.type_parameter(:A), V])
534
+ end
535
+ sig do
536
+ abstract.returns(T::Enumerator[K])
537
+ end
538
+ def transform_keys(hash2=nil, &blk); end
539
+
540
+ # Invokes the given block once for each key in *hsh*, replacing it with the
541
+ # new key returned by the block, and then returns *hsh*. This method does not
542
+ # change the values.
543
+ #
544
+ # An optional hash argument can be provided to map keys to new keys. Any key
545
+ # not given will be mapped using the provided block, or remain the same if no
546
+ # block is given.
547
+ #
548
+ # ```ruby
549
+ # h = { a: 1, b: 2, c: 3 }
550
+ # h.transform_keys! {|k| k.to_s } #=> { "a" => 1, "b" => 2, "c" => 3 }
551
+ # h.transform_keys!(&:to_sym) #=> { a: 1, b: 2, c: 3 }
552
+ # h.transform_keys!.with_index {|k, i| "#{k}.#{i}" }
553
+ # #=> { "a.0" => 1, "b.1" => 2, "c.2" => 3 }
554
+ # h.transform_keys!({ a: "a", b: "b" }) #=> { "a" => 1, "b" => 2, c: 3 }
555
+ # ```
556
+ #
557
+ # If no block is given, an enumerator is returned instead.
558
+ sig do
559
+ abstract.type_parameters(:A).params(
560
+ hash2: T.nilable(T::Hash[T.type_parameter(:A), V]),
561
+ blk: T.proc.params(arg0: K).returns(T.type_parameter(:A))
562
+ )
563
+ .returns(T::Hash[T.type_parameter(:A), V])
564
+ end
565
+ sig do
566
+ abstract.type_parameters(:A).params(
567
+ hash2: T::Hash[T.type_parameter(:A), V],
568
+ )
569
+ .returns(T::Hash[T.type_parameter(:A), V])
570
+ end
571
+ sig do
572
+ abstract.returns(T::Enumerator[K])
573
+ end
574
+ def transform_keys!(hash2=nil, &blk); end
575
+
576
+ # Returns a new hash with all keys converted by the block operation.
577
+ # This includes the keys from the root hash and from all
578
+ # nested hashes and arrays.
579
+ #
580
+ # hash = { person: { name: 'Rob', age: '28' } }
581
+ #
582
+ # hash.deep_transform_keys{ |key| key.to_s.upcase }
583
+ # # => {"PERSON"=>{"NAME"=>"Rob", "AGE"=>"28"}}
584
+ #
585
+ # source://activesupport//lib/active_support/core_ext/hash/keys.rb#65
586
+ sig do
587
+ abstract.type_parameters(:A).params(
588
+ block: T.proc.params(arg0: K).returns(T.type_parameter(:A))
589
+ )
590
+ .returns(T::Hash[T.type_parameter(:A), V])
591
+ end
592
+ sig do
593
+ abstract.returns(T::Enumerator[K])
594
+ end
595
+ def deep_transform_keys(&block); end
596
+
597
+ # Destructively converts all keys by using the block operation.
598
+ # This includes the keys from the root hash and from all
599
+ # nested hashes and arrays.
600
+ #
601
+ # source://activesupport//lib/active_support/core_ext/hash/keys.rb#72
602
+ sig do
603
+ abstract.type_parameters(:A).params(
604
+ block: T.proc.params(arg0: K).returns(T.type_parameter(:A))
605
+ )
606
+ .returns(T::Hash[T.type_parameter(:A), V])
607
+ end
608
+ sig do
609
+ abstract.returns(T::Enumerator[K])
610
+ end
611
+ def deep_transform_keys!(&block); end
612
+
613
+ # Deletes the key-value pair and returns the value from *hsh* whose key is
614
+ # equal to *key*. If the key is not found, it returns *nil*. If the optional
615
+ # code block is given and the key is not found, pass in the key and return the
616
+ # result of *block*.
617
+ #
618
+ # ```ruby
619
+ # h = { "a" => 100, "b" => 200 }
620
+ # h.delete("a") #=> 100
621
+ # h.delete("z") #=> nil
622
+ # h.delete("z") { |el| "#{el} not found" } #=> "z not found"
623
+ # ```
624
+ sig do
625
+ abstract.params(
626
+ arg0: K,
627
+ )
628
+ .returns(T.nilable(V))
629
+ end
630
+ sig do
631
+ abstract.type_parameters(:U).params(
632
+ arg0: K,
633
+ blk: T.proc.params(arg0: K).returns(T.type_parameter(:U)),
634
+ )
635
+ .returns(T.any(T.type_parameter(:U), V))
636
+ end
637
+ def delete(arg0, &blk); end
638
+
639
+ # Returns a new hash consisting of entries for which the block returns true.
640
+ #
641
+ # If no block is given, an enumerator is returned instead.
642
+ #
643
+ # ```ruby
644
+ # h = { "a" => 100, "b" => 200, "c" => 300 }
645
+ # h.select {|k,v| k > "a"} #=> {"b" => 200, "c" => 300}
646
+ # h.select {|k,v| v < 200} #=> {"a" => 100}
647
+ # ```
648
+ #
649
+ # [`Hash#filter`](https://docs.ruby-lang.org/en/2.7.0/Hash.html#method-i-filter)
650
+ # is an alias for
651
+ # [`Hash#select`](https://docs.ruby-lang.org/en/2.7.0/Hash.html#method-i-select).
652
+ sig do
653
+ abstract.params(
654
+ blk: T.proc.params(arg0: K, arg1: V).returns(BasicObject),
655
+ )
656
+ .returns(T::Hash[K, V])
657
+ end
658
+ sig {abstract.returns(T::Enumerator[[K, V]])}
659
+ def select(&blk); end
660
+
661
+ # Equivalent to
662
+ # [`Hash#keep_if`](https://docs.ruby-lang.org/en/2.7.0/Hash.html#method-i-keep_if),
663
+ # but returns `nil` if no changes were made.
664
+ #
665
+ # [`Hash#filter!`](https://docs.ruby-lang.org/en/2.7.0/Hash.html#method-i-filter-21)
666
+ # is an alias for
667
+ # [`Hash#select!`](https://docs.ruby-lang.org/en/2.7.0/Hash.html#method-i-select-21).
668
+ sig do
669
+ abstract.params(
670
+ blk: T.proc.params(arg0: K, arg1: V).returns(BasicObject),
671
+ )
672
+ .returns(T::Hash[K, V])
673
+ end
674
+ def select!(&blk); end
675
+
676
+ # Returns a new hash consisting of entries for which the block returns false.
677
+ #
678
+ # If no block is given, an enumerator is returned instead.
679
+ #
680
+ # ```ruby
681
+ # h = { "a" => 100, "b" => 200, "c" => 300 }
682
+ # h.reject {|k,v| k < "b"} #=> {"b" => 200, "c" => 300}
683
+ # h.reject {|k,v| v > 100} #=> {"a" => 100}
684
+ # ```
685
+ sig {abstract.returns(T::Enumerator[[K, V]])}
686
+ sig do
687
+ abstract.params(
688
+ blk: T.proc.params(arg0: K, arg1: V).returns(BasicObject),
689
+ )
690
+ .returns(T::Hash[K, V])
691
+ end
692
+ def reject(&blk); end
693
+
694
+ # Equivalent to
695
+ # [`Hash#delete_if`](https://docs.ruby-lang.org/en/2.7.0/Hash.html#method-i-delete_if),
696
+ # but returns `nil` if no changes were made.
697
+ sig do
698
+ abstract.params(
699
+ blk: T.proc.params(arg0: K, arg1: V).returns(BasicObject),
700
+ )
701
+ .returns(T::Hash[K, V])
702
+ end
703
+ def reject!(&blk); end
704
+
705
+ # Returns a new hash with the nil values/key pairs removed
706
+ #
707
+ # ```ruby
708
+ # h = { a: 1, b: false, c: nil }
709
+ # h.compact #=> { a: 1, b: false }
710
+ # h #=> { a: 1, b: false, c: nil }
711
+ # ```
712
+ sig { abstract.returns(Map[K, V]) }
713
+ def compact; end
714
+
715
+ # Removes all nil values from the hash. Returns nil if no changes were made,
716
+ # otherwise returns the hash.
717
+ #
718
+ # ```ruby
719
+ # h = { a: 1, b: false, c: nil }
720
+ # h.compact! #=> { a: 1, b: false }
721
+ # ```
722
+ sig { abstract.returns(Map[K, V]) }
723
+ def compact!; end
724
+
725
+ sig { abstract.returns(Map[K, V]) }
726
+ def compact_blank; end
727
+ sig { abstract.returns(Map[K, V]) }
728
+ def compact_blank!; end
729
+
730
+ # Returns `true` if the given value is present for some key in *hsh*.
731
+ #
732
+ # ```ruby
733
+ # h = { "a" => 100, "b" => 200 }
734
+ # h.value?(100) #=> true
735
+ # h.value?(999) #=> false
736
+ # ```
737
+ sig do
738
+ abstract.params(
739
+ arg0: V,
740
+ )
741
+ .returns(T::Boolean)
742
+ end
743
+ def has_value?(arg0); end
744
+
745
+ # Returns `true` if the given value is present for some key in *hsh*.
746
+ #
747
+ # ```ruby
748
+ # h = { "a" => 100, "b" => 200 }
749
+ # h.value?(100) #=> true
750
+ # h.value?(999) #=> false
751
+ # ```
752
+ sig do
753
+ abstract.params(
754
+ arg0: V,
755
+ )
756
+ .returns(T::Boolean)
757
+ end
758
+ def value?(arg0); end
759
+
760
+ # Return an array containing the values associated with the given keys. Also
761
+ # see
762
+ # [`Hash.select`](https://docs.ruby-lang.org/en/2.7.0/Hash.html#method-i-select).
763
+ #
764
+ # ```ruby
765
+ # h = { "cat" => "feline", "dog" => "canine", "cow" => "bovine" }
766
+ # h.values_at("cow", "cat") #=> ["bovine", "feline"]
767
+ # ```
768
+ sig do
769
+ abstract.params(
770
+ arg0: K,
771
+ )
772
+ .returns(T::Array[V])
773
+ end
774
+ def values_at(*arg0); end
775
+
776
+ # Returns a new hash that combines the contents of the receiver and the
777
+ # contents of the given hashes.
778
+ #
779
+ # If no block is given, entries with duplicate keys are overwritten with the
780
+ # values from each `other_hash` successively, otherwise the value for each
781
+ # duplicate key is determined by calling the block with the key, its value in
782
+ # the receiver and its value in each `other_hash`.
783
+ #
784
+ # When called without any argument, returns a copy of the receiver.
785
+ #
786
+ # ```ruby
787
+ # h1 = { "a" => 100, "b" => 200 }
788
+ # h2 = { "b" => 246, "c" => 300 }
789
+ # h3 = { "b" => 357, "d" => 400 }
790
+ # h1.merge #=> {"a"=>100, "b"=>200}
791
+ # h1.merge(h2) #=> {"a"=>100, "b"=>246, "c"=>300}
792
+ # h1.merge(h2, h3) #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
793
+ # h1.merge(h2) {|key, oldval, newval| newval - oldval}
794
+ # #=> {"a"=>100, "b"=>46, "c"=>300}
795
+ # h1.merge(h2, h3) {|key, oldval, newval| newval - oldval}
796
+ # #=> {"a"=>100, "b"=>311, "c"=>300, "d"=>400}
797
+ # h1 #=> {"a"=>100, "b"=>200}
798
+ # ```
799
+ sig do
800
+ abstract.type_parameters(:A ,:B).params(
801
+ arg0: T::Hash[T.type_parameter(:A), T.type_parameter(:B)],
802
+ )
803
+ .returns(T::Hash[T.any(T.type_parameter(:A), K), T.any(T.type_parameter(:B), V)])
804
+ end
805
+ sig do
806
+ abstract.type_parameters(:A ,:B).params(
807
+ arg0: T::Hash[T.type_parameter(:A), T.type_parameter(:B)],
808
+ blk: T.proc.params(arg0: K, arg1: V, arg2: T.type_parameter(:B)).returns(T.any(V, T.type_parameter(:B))),
809
+ )
810
+ .returns(T::Hash[T.any(T.type_parameter(:A), K), T.any(T.type_parameter(:B), V)])
811
+ end
812
+ def merge(*arg0, &blk); end
813
+
814
+ # Adds the contents of the given hashes to the receiver.
815
+ #
816
+ # If no block is given, entries with duplicate keys are overwritten with the
817
+ # values from each `other_hash` successively, otherwise the value for each
818
+ # duplicate key is determined by calling the block with the key, its value in
819
+ # the receiver and its value in each `other_hash`.
820
+ #
821
+ # ```ruby
822
+ # h1 = { "a" => 100, "b" => 200 }
823
+ # h1.merge! #=> {"a"=>100, "b"=>200}
824
+ # h1 #=> {"a"=>100, "b"=>200}
825
+ #
826
+ # h1 = { "a" => 100, "b" => 200 }
827
+ # h2 = { "b" => 246, "c" => 300 }
828
+ # h1.merge!(h2) #=> {"a"=>100, "b"=>246, "c"=>300}
829
+ # h1 #=> {"a"=>100, "b"=>246, "c"=>300}
830
+ #
831
+ # h1 = { "a" => 100, "b" => 200 }
832
+ # h2 = { "b" => 246, "c" => 300 }
833
+ # h3 = { "b" => 357, "d" => 400 }
834
+ # h1.merge!(h2, h3)
835
+ # #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
836
+ # h1 #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
837
+ #
838
+ # h1 = { "a" => 100, "b" => 200 }
839
+ # h2 = { "b" => 246, "c" => 300 }
840
+ # h3 = { "b" => 357, "d" => 400 }
841
+ # h1.merge!(h2, h3) {|key, v1, v2| v1 }
842
+ # #=> {"a"=>100, "b"=>200, "c"=>300, "d"=>400}
843
+ # h1 #=> {"a"=>100, "b"=>200, "c"=>300, "d"=>400}
844
+ # ```
845
+ #
846
+ # [`Hash#update`](https://docs.ruby-lang.org/en/2.7.0/Hash.html#method-i-update)
847
+ # is an alias for
848
+ # [`Hash#merge!`](https://docs.ruby-lang.org/en/2.7.0/Hash.html#method-i-merge-21).
849
+ sig do
850
+ abstract.type_parameters(:A ,:B).params(
851
+ other_hash: T::Hash[T.type_parameter(:A), T.type_parameter(:B)],
852
+ )
853
+ .returns(T::Hash[T.any(T.type_parameter(:A), K), T.any(T.type_parameter(:B), V)])
854
+ end
855
+ sig do
856
+ abstract.type_parameters(:A ,:B).params(
857
+ other_hash: T::Hash[T.type_parameter(:A), T.type_parameter(:B)],
858
+ blk: T.proc.params(key: K, oldval: V, newval: T.type_parameter(:B)).returns(T.any(V, T.type_parameter(:B))),
859
+ )
860
+ .returns(T::Hash[T.any(T.type_parameter(:A), K), T.any(T.type_parameter(:B), V)])
861
+ end
862
+ def merge!(*other_hash, &blk); end
863
+
864
+ # @return [Boolean]
865
+ #
866
+ # source://activesupport//lib/active_support/core_ext/hash/deep_merge.rb#40
867
+ sig { abstract.params(other: T.untyped).returns(T.untyped) }
868
+ def deep_merge?(other); end
869
+
870
+ # Merges the caller into +other_hash+. For example,
871
+ #
872
+ # options = options.reverse_merge(size: 25, velocity: 10)
873
+ #
874
+ # is equivalent to
875
+ #
876
+ # options = { size: 25, velocity: 10 }.merge(options)
877
+ #
878
+ # This is particularly useful for initializing an options hash
879
+ # with default values.
880
+ #
881
+ # source://activesupport//lib/active_support/core_ext/hash/reverse_merge.rb#14
882
+ sig do
883
+ abstract
884
+ .type_parameters(:Key, :Val)
885
+ .params(
886
+ other: Map[T.type_parameter(:Key), T.type_parameter(:Val)],
887
+ ).returns(
888
+ Map[T.any(K, T.type_parameter(:Key)), T.any(V, T.type_parameter(:Val))]
889
+ )
890
+ end
891
+ def reverse_merge(other); end
892
+
893
+ # Destructive +reverse_merge+.
894
+ #
895
+ # source://activesupport//lib/active_support/core_ext/hash/reverse_merge.rb#20
896
+ sig do
897
+ abstract
898
+ .type_parameters(:Key, :Val)
899
+ .params(
900
+ other: Map[T.type_parameter(:Key), T.type_parameter(:Val)],
901
+ ).returns(
902
+ Map[T.any(K, T.type_parameter(:Key)), T.any(V, T.type_parameter(:Val))]
903
+ )
904
+ end
905
+ def reverse_merge!(other); end
906
+
907
+ # Returns a new hash with all keys converted to strings.
908
+ #
909
+ # hash = { name: 'Rob', age: '28' }
910
+ #
911
+ # hash.stringify_keys
912
+ # # => {"name"=>"Rob", "age"=>"28"}
913
+ #
914
+ # source://activesupport//lib/active_support/core_ext/hash/keys.rb#10
915
+ sig {abstract.returns(Map[String, V])}
916
+ def stringify_keys; end
917
+
918
+ sig { abstract.returns(String) }
919
+ def inspect; end
920
+
921
+ # Returns a deep copy of hash.
922
+ #
923
+ # hash = { a: { b: 'b' } }
924
+ # dup = hash.deep_dup
925
+ # dup[:a][:c] = 'c'
926
+ #
927
+ # hash[:a][:c] # => nil
928
+ # dup[:a][:c] # => "c"
929
+ #
930
+ # source://activesupport//lib/active_support/core_ext/object/deep_dup.rb#43
931
+ sig { abstract.returns(Map[K, V])}
932
+ def deep_dup; end
933
+ end