The example below creates a refinement module which adds a method to instances of Integer
. In the Test
class, we bring it into scope by declaring using Refinements
. Next, we create an instance method using def_delegators
named Test#xxx
that calls @k.xxx
, which should resolve to the refinement method we added to Integer
. Finally, we "manually" create essentially the same method, this time named yyy
, but we define it "manually" without using def_delegators
.
require "forwardable"
module Refinements
refine Integer do
def xxx