Skip to content

Commit

Permalink
Work around broken p-methods in gemified sorted_set
Browse files Browse the repository at this point in the history
  • Loading branch information
jaynetics committed Jan 9, 2021
1 parent c50c861 commit 387c352
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/character_set/ruby_fallback/set_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def #{mthd}(enum, &block)
RUBY
end

%i[<< === add add? clear collect! delete delete? delete_if
each filter! hash include? map! member? keep_if reject!
%i[<< add add? clear collect! delete delete? delete_if
each filter! hash map! keep_if reject!
select! subtract].each do |mthd|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{mthd}(*args, &block)
Expand All @@ -34,6 +34,15 @@ def #{mthd}(*args, &block)
RUBY
end

# revert if https://github.com/knu/sorted_set/issues/2 is resolved
%i[=== include? member?].each do |mthd|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{mthd}(*args, &block)
!!@__set.#{mthd}(*args, &block)
end
RUBY
end

%i[& + - ^ | difference intersection union].each do |mthd|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{mthd}(enum, &block)
Expand Down

0 comments on commit 387c352

Please sign in to comment.