From c834a751d2acbd55b580cbba2e96dd29c5d9a452 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 16 Mar 2011 21:19:35 -0300 Subject: define_attr_method correctly defines methods with invalid identifiers --- activemodel/lib/active_model/attribute_methods.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'activemodel/lib/active_model') diff --git a/activemodel/lib/active_model/attribute_methods.rb b/activemodel/lib/active_model/attribute_methods.rb index 2a99450a3d..21ddef6b75 100644 --- a/activemodel/lib/active_model/attribute_methods.rb +++ b/activemodel/lib/active_model/attribute_methods.rb @@ -108,9 +108,8 @@ module ActiveModel else # use eval instead of a block to work around a memory leak in dev # mode in fcgi - sing.class_eval <<-eorb, __FILE__, __LINE__ + 1 - def #{name}; #{value.nil? ? 'nil' : value.to_s.inspect}; end - eorb + value = value.nil? ? 'nil' : value.to_s + sing.send(:define_method, name) { value } end end -- cgit v1.2.3