def alias_and_capture(klazz, m_sym, flag, &blk)
      alias_m_sym = "__alias_#{m_sym}"

      klazz.class_eval do
        alias_method alias_m_sym, m_sym

        define_method(m_sym) do |*args, &blx|
         response = send(alias_m_sym, *args, &blx)
           blk.call(self, *args) if flag.get_set
         response
        end
      end
    end
def alias_and_capture(klazz, m_sym, flag, &blk)
      alias_m_sym = "__alias_#{m_sym}"

      klazz.class_eval do
        alias_method alias_m_sym, m_sym

        define_method(m_sym) do |*args, &blx|
         response = send(alias_m_sym, *args, &blx)
           blk.call(self, *args) if flag.get_set
         response
        end
      end
    end
Cracks open the target class, and injects a wrapper to enable
 monitoring. By aliasing the original method the wrapper intercepts the
 call, which it forwards onto the 'real' method before executing the hook.

 The hook's functionality is provided via a &block, which is passed the
 caller's +self+ in addition to the wrapped method's parameters.

 Locking the +flag+ signals the hook to begin capturing.