diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-07-30 16:52:00 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-07-30 17:54:02 -0500 |
commit | 1ae7eb52006229f6d6975837f0ac1410e366d456 (patch) | |
tree | ef80ffff0db147ad1337de4a08a033a73f508b27 /activerecord | |
parent | d599ea27c563af2a79ccad3cabc0a1efd4c2427f (diff) | |
download | rails-1ae7eb52006229f6d6975837f0ac1410e366d456.tar.gz rails-1ae7eb52006229f6d6975837f0ac1410e366d456.tar.bz2 rails-1ae7eb52006229f6d6975837f0ac1410e366d456.zip |
Make sure to reset defined methods after calling attribute_method_suffix
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods.rb | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index e7f3f4cba5..90a6a21981 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -34,8 +34,9 @@ module ActiveRecord # person.name = 'Hubert' # person.name_changed? # => true def attribute_method_suffix(*suffixes) - attribute_method_suffixes.concat suffixes + attribute_method_suffixes.concat(suffixes) rebuild_attribute_method_regexp + undefine_attribute_methods end # Returns MatchData if method_name is an attribute method. @@ -101,12 +102,12 @@ module ActiveRecord # Evaluate the definition for an attribute related method def evaluate_attribute_method(method_definition, method_name) - generated_methods << method_name + generated_methods << method_name.to_s begin class_eval(method_definition, __FILE__, __LINE__) rescue SyntaxError => err - generated_methods.delete(method_name) + generated_methods.delete(method_name.to_s) if logger logger.warn "Exception occurred during reader method compilation." logger.warn "Maybe #{method_name} is not a valid Ruby identifier?" @@ -137,17 +138,14 @@ module ActiveRecord end end - guard_private_attribute_method!(method_name, args) if md = self.class.match_attribute_method?(method_name) attribute_name, method_type = md.pre_match, md.to_s if attribute_name == 'id' || @attributes.include?(attribute_name) - __send__("attribute#{method_type}", attribute_name, *args, &block) - else - super + guard_private_attribute_method!(method_name, args) + return __send__("attribute#{method_type}", attribute_name, *args, &block) end - else - super end + super end # A Person object with a name attribute can ask <tt>person.respond_to?(:name)</tt>, |