Skip to content

Commit 11eab86

Browse files
marianosimonecopybara-github
authored andcommitted
[Ruby] Delegate difference, intersection, union from RepeatedField to Array (#15652)
Coming from [[protobuf/issues/15180] [Ruby] Support for currently ignored Array methods in `RepeatedField`](#15180) This adds a couple of `Array` methods to what gets delegated from `RepeatedField`. - `intersection`, because `|` was already delegated - `union`, because `&` was already delegated - `difference`, because `-` was already delegated Closes #15652 COPYBARA_INTEGRATE_REVIEW=#15652 from marianosimone:delegate_rb_array_methods 2971981 PiperOrigin-RevId: 604534655
1 parent c98bdc2 commit 11eab86

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

ruby/lib/google/protobuf/repeated_field.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ class RepeatedField
4747
def_delegators :to_ary,
4848
:&, :*, :-, :'<=>',
4949
:assoc, :bsearch, :bsearch_index, :combination, :compact, :count,
50-
:cycle, :dig, :drop, :drop_while, :eql?, :fetch, :find_index, :flatten,
51-
:include?, :index, :inspect, :join,
50+
:cycle, :difference, :dig, :drop, :drop_while, :eql?, :fetch, :find_index, :flatten,
51+
:include?, :index, :inspect, :intersection, :join,
5252
:pack, :permutation, :product, :pretty_print, :pretty_print_cycle,
5353
:rassoc, :repeated_combination, :repeated_permutation, :reverse,
5454
:rindex, :rotate, :sample, :shuffle, :shelljoin,
55-
:to_s, :transpose, :uniq, :|
55+
:to_s, :transpose, :union, :uniq, :|
5656

5757

5858
def first(n=nil)

ruby/tests/repeated_field_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ def test_acts_like_an_array
2222
arr_methods -= [ :indices, :iter_for_each, :iter_for_each_index,
2323
:iter_for_each_with_index, :dimensions, :copy_data, :copy_data_simple,
2424
:nitems, :iter_for_reverse_each, :indexes, :append, :prepend]
25-
arr_methods -= [:union, :difference, :filter!]
25+
arr_methods -= [:filter!]
2626
# ruby 2.7 methods we can ignore
27-
arr_methods -= [:intersection, :deconstruct, :resolve_feature_path]
27+
arr_methods -= [:deconstruct, :resolve_feature_path]
2828
# ruby 3.1 methods we can ignore
2929
arr_methods -= [:intersect?]
3030
arr_methods.each do |method_name|

0 commit comments

Comments
 (0)