Using refinements to patch a core Module such as Kernel
<p>I'm going through the Facets API and picking some methods to include in my refinement-compatible patch library. </p>

<p>I've hit a snag trying to patch Kernel. It's a module, whereas the other stuff I've patched has been classes (String, Array, etc.)</p>

<hr>

<p>Here's proof that can't can't be refined using my standard approach for core classes:</p>

<pre><code>module Patch
  refine Kernel do
    def patched?
      true
    end
  end
end

# TypeError: wrong argument type Module (expected Class)
# from (pry):16:in `refine' 
</code></pre>

<hr>

<p>I've also tried wrapping the Kernel module in a class, and changing the global reference to Kernel to that class.</p>

<pre><code>class MyKernel
  include Kernel
  extend Kernel
end

# not sure if Object::Kernel is really the global reference
Object::Kernel = MyKernel

module Patch
  refine MyKernel do
    def patched?
      true
     end
  end
end

class Test
  using Patch
  patched?
end
# NoMethodError: undefined method `patched?' for Test:Class
# from (pry):15:in `&lt;class:Test&gt;'
</code></pre>

<hr>

<p>In this case I could successfully get the same functionality by replacing Kernel with Object:</p>

<pre><code>module Patch
  refine Object do
    def patched?
      true
     end
  end
end

class Test
  using Patch
  patched?
end
</code></pre>

<p>But I'm not sure if I could get this equivalency with other core modules such as Enumerable. </p>