Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Wrapping a class method by including a module
module Wrapper
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def wrap!
class << self
alias_method :original_perform, :perform
def perform(*args)
original_perform(*args)
# add in anything you want to do now
end
end
end
def singleton_method_added(name)
wrap! if name == :perform && !self.respond_to?(:original_perform)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.