From cff25aae90859d5f47d827b162b505f8b316b733 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Wed, 10 Oct 2007 23:01:18 +0000 Subject: eval with __FILE__ and __LINE__ git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7827 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/lib/active_record/aggregations.rb | 10 +++++----- activerecord/lib/active_record/attribute_methods.rb | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/activerecord/lib/active_record/aggregations.rb b/activerecord/lib/active_record/aggregations.rb index 5be629e3d5..8c3cdc3c11 100644 --- a/activerecord/lib/active_record/aggregations.rb +++ b/activerecord/lib/active_record/aggregations.rb @@ -153,7 +153,7 @@ module ActiveRecord "true" end - module_eval <<-end_eval + module_eval <<-end_eval, __FILE__, __LINE__ def #{name}(force_reload = false) if (@#{name}.nil? || force_reload) && #{allow_nil_condition} @#{name} = #{class_name}.new(#{mapping.collect { |pair| "read_attribute(\"#{pair.first}\")"}.join(", ")}) @@ -161,13 +161,13 @@ module ActiveRecord return @#{name} end end_eval - end - + end + def writer_method(name, class_name, mapping, allow_nil) mapping = (Array === mapping.first ? mapping : [ mapping ]) if allow_nil - module_eval <<-end_eval + module_eval <<-end_eval, __FILE__, __LINE__ def #{name}=(part) if part.nil? #{mapping.collect { |pair| "@attributes[\"#{pair.first}\"] = nil" }.join("\n")} @@ -178,7 +178,7 @@ module ActiveRecord end end_eval else - module_eval <<-end_eval + module_eval <<-end_eval, __FILE__, __LINE__ def #{name}=(part) @#{name} = part.freeze #{mapping.collect{ |pair| "@attributes[\"#{pair.first}\"] = part.#{pair.last}" }.join("\n")} diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index dc0bd2d125..118b596591 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -157,7 +157,7 @@ module ActiveRecord end begin - class_eval(method_definition) + class_eval(method_definition, __FILE__, __LINE__) rescue SyntaxError => err generated_methods.delete(attr_name) if logger -- cgit v1.2.3