aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/attribute_methods.rb
diff options
context:
space:
mode:
authorOscar Del Ben <info@oscardelben.com>2012-04-02 16:41:43 +0300
committerOscar Del Ben <info@oscardelben.com>2012-05-18 08:50:57 -0700
commit42d0b1c8ddab9c3ffa8951bf085f5c758673e94b (patch)
treece05a829b23b8e15e40569de416f0871874cd2f9 /activemodel/lib/active_model/attribute_methods.rb
parent1ae68ea35fcbdf43fd86bbf665c67266d61f1308 (diff)
downloadrails-42d0b1c8ddab9c3ffa8951bf085f5c758673e94b.tar.gz
rails-42d0b1c8ddab9c3ffa8951bf085f5c758673e94b.tar.bz2
rails-42d0b1c8ddab9c3ffa8951bf085f5c758673e94b.zip
Call undefine_attribute_methods only when defining new attributes
Diffstat (limited to 'activemodel/lib/active_model/attribute_methods.rb')
-rw-r--r--activemodel/lib/active_model/attribute_methods.rb4
1 files changed, 1 insertions, 3 deletions
diff --git a/activemodel/lib/active_model/attribute_methods.rb b/activemodel/lib/active_model/attribute_methods.rb
index 99918fdb96..039cd8bdf3 100644
--- a/activemodel/lib/active_model/attribute_methods.rb
+++ b/activemodel/lib/active_model/attribute_methods.rb
@@ -102,7 +102,6 @@ module ActiveModel
# person.name # => nil
def attribute_method_prefix(*prefixes)
self.attribute_method_matchers += prefixes.map { |prefix| AttributeMethodMatcher.new :prefix => prefix }
- undefine_attribute_methods
end
# Declares a method available for all attributes with the given suffix.
@@ -139,7 +138,6 @@ module ActiveModel
# person.name_short? # => true
def attribute_method_suffix(*suffixes)
self.attribute_method_matchers += suffixes.map { |suffix| AttributeMethodMatcher.new :suffix => suffix }
- undefine_attribute_methods
end
# Declares a method available for all attributes with the given prefix
@@ -177,7 +175,6 @@ module ActiveModel
# person.name # => 'Gemma'
def attribute_method_affix(*affixes)
self.attribute_method_matchers += affixes.map { |affix| AttributeMethodMatcher.new :prefix => affix[:prefix], :suffix => affix[:suffix] }
- undefine_attribute_methods
end
@@ -225,6 +222,7 @@ module ActiveModel
# end
# end
def define_attribute_methods(*attr_names)
+ undefine_attribute_methods
attr_names.flatten.each { |attr_name| define_attribute_method(attr_name) }
end