提交 fbab7b2a 编写于 作者: P Piotr Sarnacki

Revert "methods are defined right after the module_eval, so we don't need to do"

This change breaks tests in activesupport/test/core_ext/module_test.rb:

* test_delegation_exception_backtrace
* test_delegation_exception_backtrace_with_allow_nil

This reverts commit 0167765e.
上级 2e0f9ed7
......@@ -178,7 +178,7 @@ def delegate(*methods)
# whereas conceptually, from the user point of view, the delegator should
# be doing one call.
if allow_nil
module_eval(<<-EOS, file, line)
module_eval(<<-EOS, file, line - 3)
def #{method_prefix}#{method}(#{definition}) # def customer_name(*args, &block)
_ = #{to} # _ = client
if !_.nil? || nil.respond_to?(:#{method}) # if !_.nil? || nil.respond_to?(:name)
......@@ -189,7 +189,7 @@ def #{method_prefix}#{method}(#{definition}) # def customer_name(*args, &
else
exception = %(raise DelegationError, "#{self}##{method_prefix}#{method} delegated to #{to}.#{method}, but #{to} is nil: \#{self.inspect}")
module_eval(<<-EOS, file, line)
module_eval(<<-EOS, file, line - 2)
def #{method_prefix}#{method}(#{definition}) # def customer_name(*args, &block)
_ = #{to} # _ = client
_.#{method}(#{definition}) # _.name(*args, &block)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册