title: Inject callback from a class method defined in a module
body: <p>I want to mimic what AR does with <code>after_save ..., if: -&gt; { bar? }</code> but I don't understand how I can change context to set <code>self</code> to the object.</p>
  
  <pre><code>module MyModule
    extend ActiveSupport::Concern
  
    module ClassMethods
      def add_callback(options)
        foo = options.fetch(:foo)
  
        the_real_callback = -&gt; do
          puts foo.call(self).inspect
        end
  
        before_save(the_real_callback)
      end
    end
  end
  
  class MyClass &lt; ActiveRecord::Base
    include MyModule
  
    add_callback foo: -&gt;(instance) { instance.bar }
  
    def bar
      "bar"
    end
  end
  
  o = MyClass.new
  o.save
  # displays "bar"
  </code></pre>
  
  <p>I want to replace <code>add_callback foo: -&gt;(instance) { instance.bar }</code> with <code>add_callback foo -&gt; { bar }</code></p>