Skip to content

Commit

Permalink
Merge pull request rails#5702 from oscardelben/patch-4
Browse files Browse the repository at this point in the history
Call undefine_attribute_methods only when defining new attributes
  • Loading branch information
drogus committed May 20, 2012
2 parents da97cf0 + 42d0b1c commit cae1ca7
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions activemodel/lib/active_model/attribute_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ module ClassMethods
# 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.
Expand Down Expand Up @@ -139,7 +138,6 @@ def attribute_method_prefix(*prefixes)
# 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
Expand Down Expand Up @@ -177,7 +175,6 @@ def attribute_method_suffix(*suffixes)
# 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


Expand Down Expand Up @@ -225,6 +222,7 @@ def alias_attribute(new_name, old_name)
# end
# end
def define_attribute_methods(*attr_names)
undefine_attribute_methods
attr_names.flatten.each { |attr_name| define_attribute_method(attr_name) }
end

Expand Down

0 comments on commit cae1ca7

Please sign in to comment.