From aacf2581cde0147dc66c3eeacf6d7447c2bbafdf Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 19 May 2010 16:37:41 -0300 Subject: refactor evals and adds some __FILE__ and __LINE__ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- activeresource/lib/active_resource/base.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'activeresource') diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb index b976844c1c..6397fbc280 100644 --- a/activeresource/lib/active_resource/base.rb +++ b/activeresource/lib/active_resource/base.rb @@ -582,12 +582,13 @@ module ActiveResource # Clear prefix parameters in case they have been cached @prefix_parameters = nil - # Redefine the new methods. - code, line = <<-end_code, __LINE__ + 1 - def prefix_source() "#{value}" end - def prefix(options={}) "#{prefix_call}" end - end_code - silence_warnings { instance_eval code, __FILE__, line } + silence_warnings do + # Redefine the new methods. + instance_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 + def prefix_source() "#{value}" end + def prefix(options={}) "#{prefix_call}" end + RUBY_EVAL + end rescue logger.error "Couldn't set prefix: #{$!}\n #{code}" if logger raise -- cgit v1.2.3