aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/inheritance.rb
diff options
context:
space:
mode:
authorBogdan Gusiev <agresso@gmail.com>2018-04-02 14:17:24 +0300
committerBogdan Gusiev <agresso@gmail.com>2018-04-02 14:34:32 +0300
commit0d9f45ff99c092cce6b7642f653b8fdf9f930f0c (patch)
tree9d98aa6242dde4a480b2543961b6b8498b6233ab /activerecord/lib/active_record/inheritance.rb
parent09b2348f7fc8d4e7191e70e06608c5909067e2aa (diff)
downloadrails-0d9f45ff99c092cce6b7642f653b8fdf9f930f0c.tar.gz
rails-0d9f45ff99c092cce6b7642f653b8fdf9f930f0c.tar.bz2
rails-0d9f45ff99c092cce6b7642f653b8fdf9f930f0c.zip
Add AR::Base.base_class? predicate
Diffstat (limited to 'activerecord/lib/active_record/inheritance.rb')
-rw-r--r--activerecord/lib/active_record/inheritance.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/inheritance.rb b/activerecord/lib/active_record/inheritance.rb
index 208ba95c52..6891c575c7 100644
--- a/activerecord/lib/active_record/inheritance.rb
+++ b/activerecord/lib/active_record/inheritance.rb
@@ -55,7 +55,7 @@ module ActiveRecord
if has_attribute?(inheritance_column)
subclass = subclass_from_attributes(attributes)
- if subclass.nil? && base_class == self
+ if subclass.nil? && base_class?
subclass = subclass_from_attributes(column_defaults)
end
end
@@ -104,6 +104,12 @@ module ActiveRecord
end
end
+ # Returns whether the class is a base class.
+ # See #base_class for more information.
+ def base_class?
+ base_class == self
+ end
+
# Set this to +true+ if this is an abstract class (see
# <tt>abstract_class?</tt>).
# If you are using inheritance with Active Record and don't want a class