File tree Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Original file line number Diff line number Diff line change
1
+ * ActiveSupport::HashWithIndifferentAccess ` select ` and ` reject ` will now return
2
+ enumerator if called without block.
3
+
4
+ Fixes #20095
5
+
6
+ * Bernard Potocki*
7
+
1
8
* Removed ` ActiveSupport::Concurrency::Latch ` , superseded by ` Concurrent::CountDownLatch `
2
9
from the concurrent-ruby gem.
3
10
Original file line number Diff line number Diff line change @@ -238,10 +238,12 @@ def deep_symbolize_keys; to_hash.deep_symbolize_keys! end
238
238
def to_options! ; self end
239
239
240
240
def select ( *args , &block )
241
+ return to_enum ( :select ) unless block_given?
241
242
dup . tap { |hash | hash . select! ( *args , &block ) }
242
243
end
243
244
244
245
def reject ( *args , &block )
246
+ return to_enum ( :reject ) unless block_given?
245
247
dup . tap { |hash | hash . reject! ( *args , &block ) }
246
248
end
247
249
Original file line number Diff line number Diff line change @@ -551,6 +551,11 @@ def test_indifferent_select
551
551
assert_instance_of ActiveSupport ::HashWithIndifferentAccess , hash
552
552
end
553
553
554
+ def test_indifferent_select_returns_enumerator
555
+ enum = ActiveSupport ::HashWithIndifferentAccess . new ( @strings ) . select
556
+ assert_instance_of Enumerator , enum
557
+ end
558
+
554
559
def test_indifferent_select_returns_a_hash_when_unchanged
555
560
hash = ActiveSupport ::HashWithIndifferentAccess . new ( @strings ) . select { |k , v | true }
556
561
@@ -572,6 +577,11 @@ def test_indifferent_reject
572
577
assert_instance_of ActiveSupport ::HashWithIndifferentAccess , hash
573
578
end
574
579
580
+ def test_indifferent_reject_returns_enumerator
581
+ enum = ActiveSupport ::HashWithIndifferentAccess . new ( @strings ) . reject
582
+ assert_instance_of Enumerator , enum
583
+ end
584
+
575
585
def test_indifferent_reject_bang
576
586
indifferent_strings = ActiveSupport ::HashWithIndifferentAccess . new ( @strings )
577
587
indifferent_strings . reject! { |k , v | v != 1 }
You can’t perform that action at this time.
0 commit comments