Rename a method added by a gem

metaprogramming, ruby, sidekiq

Solution

After the relevant gem is included:

module Sidekiq::Extensions::Klass
  alias :sidekiq_delay :delay
  remove_method :delay
end

Problem

I want to rename the `delay` method added by the Sidekiq gem to `sidekiq_delay`. This extension method is added to all classes in Ruby. How can I use Ruby meta-programming to do this? I want to do this so Sidekiq's `delay` will not override Delay Job's `delay` method.

Original source