Report correct file/line in backtraces for attr_rw methods

This commit is contained in:
Jack Nagel 2013-12-12 14:16:43 -06:00
parent c0d199759f
commit 00d0de5b24

View File

@ -1,7 +1,10 @@
class Module
def attr_rw(*attrs)
file, line, _ = caller.first.split(":")
line = line.to_i
attrs.each do |attr|
module_eval <<-EOS, __FILE__, __LINE__ + 1
module_eval <<-EOS, file, line
def #{attr}(val=nil)
val.nil? ? @#{attr} : @#{attr} = val
end