diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-07-30 14:16:36 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-07-30 17:54:01 -0500 |
commit | 89e9efcbe245475dec1206373755f075e17fa3e2 (patch) | |
tree | bdb72200a1fe350e703d91790749edceabff1789 /activerecord/lib/active_record | |
parent | 2c30c9fe6c22f0342aa0be3909efa3a5787dc33d (diff) | |
download | rails-89e9efcbe245475dec1206373755f075e17fa3e2.tar.gz rails-89e9efcbe245475dec1206373755f075e17fa3e2.tar.bz2 rails-89e9efcbe245475dec1206373755f075e17fa3e2.zip |
Don't need to pass attr_name to evaluate_attribute_method anymore
Diffstat (limited to 'activerecord/lib/active_record')
4 files changed, 9 insertions, 9 deletions
diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index 4c9ea050c4..8686db1793 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -72,7 +72,7 @@ module ActiveRecord if respond_to?(generate_method) send(generate_method, name) else - evaluate_attribute_method(name, "def #{method_name}(*args); attribute#{suffix}('#{name}', *args); end", method_name) + evaluate_attribute_method("def #{method_name}(*args); attribute#{suffix}('#{name}', *args); end", method_name) end end end @@ -110,16 +110,16 @@ module ActiveRecord end # Evaluate the definition for an attribute related method - def evaluate_attribute_method(attr_name, method_definition, method_name) + def evaluate_attribute_method(method_definition, method_name) generated_methods << method_name begin class_eval(method_definition, __FILE__, __LINE__) rescue SyntaxError => err - generated_methods.delete(attr_name) + generated_methods.delete(method_name) if logger logger.warn "Exception occurred during reader method compilation." - logger.warn "Maybe #{attr_name} is not a valid Ruby identifier?" + logger.warn "Maybe #{method_name} is not a valid Ruby identifier?" logger.warn err.message end end diff --git a/activerecord/lib/active_record/attribute_methods/read.rb b/activerecord/lib/active_record/attribute_methods/read.rb index 2ea09499c5..1178c713b4 100644 --- a/activerecord/lib/active_record/attribute_methods/read.rb +++ b/activerecord/lib/active_record/attribute_methods/read.rb @@ -40,7 +40,7 @@ module ActiveRecord private # Define read method for serialized attribute. def define_read_method_for_serialized_attribute(attr_name) - evaluate_attribute_method attr_name, "def #{attr_name}; unserialize_attribute('#{attr_name}'); end", attr_name + evaluate_attribute_method "def #{attr_name}; unserialize_attribute('#{attr_name}'); end", attr_name end # Define an attribute reader method. Cope with nil column. @@ -55,7 +55,7 @@ module ActiveRecord if cache_attribute?(attr_name) access_code = "@attributes_cache['#{attr_name}'] ||= (#{access_code})" end - evaluate_attribute_method attr_name, "def #{symbol}; #{access_code}; end", symbol + evaluate_attribute_method "def #{symbol}; #{access_code}; end", symbol end end diff --git a/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb b/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb index f379b4c0f8..9e2c6174c6 100644 --- a/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb +++ b/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb @@ -25,7 +25,7 @@ module ActiveRecord @attributes_cache['#{attr_name}'] = time.acts_like?(:time) ? time.in_time_zone : time end EOV - evaluate_attribute_method attr_name, method_body, attr_name + evaluate_attribute_method method_body, attr_name else super end @@ -44,7 +44,7 @@ module ActiveRecord write_attribute(:#{attr_name}, time) end EOV - evaluate_attribute_method attr_name, method_body, "#{attr_name}=" + evaluate_attribute_method method_body, "#{attr_name}=" else super end diff --git a/activerecord/lib/active_record/attribute_methods/write.rb b/activerecord/lib/active_record/attribute_methods/write.rb index b4f2f6eb1d..497e72ee4a 100644 --- a/activerecord/lib/active_record/attribute_methods/write.rb +++ b/activerecord/lib/active_record/attribute_methods/write.rb @@ -10,7 +10,7 @@ module ActiveRecord module ClassMethods protected def define_attribute_method=(attr_name) - evaluate_attribute_method attr_name, "def #{attr_name}=(new_value); write_attribute('#{attr_name}', new_value); end", "#{attr_name}=" + evaluate_attribute_method "def #{attr_name}=(new_value); write_attribute('#{attr_name}', new_value); end", "#{attr_name}=" end end |