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