module Jekyll::Algolia::Utils
def self.monkey_patch(instance, method, block)
Solution found on
block - The new block to use for replacing (as a proc)
method - The method symbol to overwrite
instance - The instance to overwrite
Public: Allow redefining an instance method on the fly with a new one
def self.monkey_patch(instance, method, block) metaclass = class << instance; self; end metaclass.send(:define_method, method, block) end