aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/inheritance.rb
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-12-28 18:07:08 +0000
committerJon Leighton <j@jonathanleighton.com>2011-12-28 18:27:41 +0000
commitdae7b6545372cba40e08554b9a7b2f391eaa5c6e (patch)
tree6035c63c71dc0243560412b08110bd7e496f8552 /activerecord/lib/active_record/inheritance.rb
parent93c1f11c0a5097a5431819a1551a02a869a16a38 (diff)
downloadrails-dae7b6545372cba40e08554b9a7b2f391eaa5c6e.tar.gz
rails-dae7b6545372cba40e08554b9a7b2f391eaa5c6e.tar.bz2
rails-dae7b6545372cba40e08554b9a7b2f391eaa5c6e.zip
Support establishing connection on ActiveRecord::Model.
This is the 'top level' connection, inherited by any models that include ActiveRecord::Model or inherit from ActiveRecord::Base.
Diffstat (limited to 'activerecord/lib/active_record/inheritance.rb')
-rw-r--r--activerecord/lib/active_record/inheritance.rb20
1 files changed, 8 insertions, 12 deletions
diff --git a/activerecord/lib/active_record/inheritance.rb b/activerecord/lib/active_record/inheritance.rb
index 0e92b7cf41..eaa7deac5a 100644
--- a/activerecord/lib/active_record/inheritance.rb
+++ b/activerecord/lib/active_record/inheritance.rb
@@ -17,8 +17,10 @@ module ActiveRecord
if sup.abstract_class?
sup.descends_from_active_record?
+ elsif self == Base
+ false
else
- sup == Base || !columns_hash.include?(inheritance_column)
+ [Base, Model].include?(sup) || !columns_hash.include?(inheritance_column)
end
end
@@ -81,18 +83,12 @@ module ActiveRecord
instance
end
- # If this class includes ActiveRecord::Model then it won't have a
- # superclass. So this provides a way to get to the 'root' (ActiveRecord::Base),
- # through inheritance hierarchy, ending in Base, whether or not that is
- # actually an ancestor of the class.
+ # For internal use.
#
- # Mainly for internal use.
+ # If this class includes ActiveRecord::Model then it won't have a
+ # superclass. So this provides a way to get to the 'root' (ActiveRecord::Model).
def active_record_super #:nodoc:
- if self == Base || superclass && superclass < Model
- superclass
- else
- Base
- end
+ superclass < Model ? superclass : Model
end
protected
@@ -105,7 +101,7 @@ module ActiveRecord
end
sup = klass.active_record_super
- if klass == Base || sup == Base || sup.abstract_class?
+ if [Base, Model].include?(klass) || [Base, Model].include?(sup) || sup.abstract_class?
klass
else
class_of_active_record_descendant(sup)