define_advised_method (Extlib::Hook::ClassMethods)

    # File lib/extlib/hook.rb, line 275
          def define_advised_method(target_method, scope)
            args = args_for(method_with_scope(target_method, scope))

            renamed_target = hook_method_name(target_method, 'hookable_', 'before_advised')

            source = "def \#{target_method}(\#{args})\nretval = nil\ncatch(:halt) do\n\#{hook_method_name(target_method, 'execute_before', 'hook_stack')}(\#{args})\nretval = \#{renamed_target}(\#{args})\n\#{hook_method_name(target_method, 'execute_after', 'hook_stack')}(retval, \#{args})\nretval\nend\nend\n"

            if scope == :instance && !instance_methods(false).any? { |m| m.to_sym == target_method }
              send(:alias_method, renamed_target, target_method)

              proxy_module = Module.new
              proxy_module.class_eval(source, __FILE__, __LINE__)
              self.send(:include, proxy_module)
            else
              source = %{alias_method :#{renamed_target}, :#{target_method}\n#{source}}
              source = %{class << self\n#{source}\nend} if scope == :class
              class_eval(source, __FILE__, __LINE__)
            end
          end