Permalink
Browse files

Delegated methods report the expected file/line in backtraces

  • Loading branch information...
1 parent a491b19 commit b75bc05bc540f2e9efaf41d3a1540787aaa58d19 @jeremy jeremy committed Jun 18, 2009
Showing with 4 additions and 1 deletion.
  1. +4 −1 activesupport/lib/active_support/core_ext/module/delegation.rb
View
5 activesupport/lib/active_support/core_ext/module/delegation.rb
@@ -110,8 +110,11 @@ def delegate(*methods)
allow_nil = options[:allow_nil] && "#{to} && "
+ file, line = caller.first.split(':', 2)
+ line = line.to_i
+
methods.each do |method|
- module_eval(<<-EOS, "(__DELEGATION__)", 1)
+ module_eval(<<-EOS, file, line)
def #{prefix}#{method}(*args, &block) # def customer_name(*args, &block)
#{allow_nil}#{to}.__send__(#{method.inspect}, *args, &block) # client && client.__send__(:name, *args, &block)
end # end

0 comments on commit b75bc05

Please sign in to comment.