---
title: "module中的函数重定义之后，如何re-mixins？"
author: "jack"
date: "2007-08-14T15:43:49Z"
tags: []
slug: "module-re-mixins"
draft: false
lastmod: "2007-08-14T15:43:49Z"
id: 112127
url: "https://jack.iteye.com/blog/112127"
---

需要在页面上输出每次require的调用时间。于是修改了 rails中的一个 方法，方法是module的一部分 。但是 如何remixins，却是大问题了。

或者另外一个方法直接修改 mixins以后的代码。 但是嵌套了多个module之后， 不清楚怎么去修改这个方法了。

以下是代码



```

module ActionController #:nodoc:
  module Benchmarking #:nodoc:
    module ClassMethods

      def perform_action_with_benchmark
        unless logger
          perform_action_without_benchmark
        else
          runtime = [benchmark::measure{ perform_action_without_benchmark }.real, 0.0001].max
          @runtime_require = runtime #这句是添加的代码

          log_message  = "Completed inaa #{sprintf("%.5f", runtime)} (#{(1 / runtime).floor} reqs/sec)"
          log_message << rendering_runtime(runtime) if defined?(@rendering_runtime)
          log_message << active_record_runtime(runtime) if Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected?
          log_message << " | #{headers["status"]}"
          log_message << " [#{complete_request_uri rescue "unknown"}]"
          logger.info(log_message)
        end
      end
    end
  end
end
```