aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-02-18 15:51:39 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2011-02-18 15:51:39 -0800
commit30679bc705c74fcf1d26df275134f7b655a288a8 (patch)
tree09ee3ea20859f5d9469c8235ebd6bd3fffb0f608 /activerecord/lib/active_record
parentce76cfc61f86931d5acc6db3c2c438cd5ea98255 (diff)
downloadrails-30679bc705c74fcf1d26df275134f7b655a288a8.tar.gz
rails-30679bc705c74fcf1d26df275134f7b655a288a8.tar.bz2
rails-30679bc705c74fcf1d26df275134f7b655a288a8.zip
AR::AttributeMethods does not need to be included in an AR::Base class.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/attribute_methods.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb
index 2c5db51f7f..40ff273846 100644
--- a/activerecord/lib/active_record/attribute_methods.rb
+++ b/activerecord/lib/active_record/attribute_methods.rb
@@ -18,7 +18,11 @@ module ActiveRecord
# method is defined by Active Record though.
def instance_method_already_implemented?(method_name)
method_name = method_name.to_s
- @_defined_class_methods ||= ancestors.first(ancestors.index(ActiveRecord::Base)).sum([]) { |m| m.instance_methods(false) | m.private_instance_methods(false) }.map {|m| m.to_s }.to_set
+ index = ancestors.index(ActiveRecord::Base) || ancestors.length
+ @_defined_class_methods ||= ancestors.first(index).map { |m|
+ m.instance_methods(false) | m.private_instance_methods(false)
+ }.flatten.map {|m| m.to_s }.to_set
+
@@_defined_activerecord_methods ||= defined_activerecord_methods
raise DangerousAttributeError, "#{method_name} is defined by ActiveRecord" if @@_defined_activerecord_methods.include?(method_name)
@_defined_class_methods.include?(method_name)