@@ -94,14 +94,24 @@ def finder_needs_type_condition? # :nodoc:
94
94
:true == ( @finder_needs_type_condition ||= descends_from_active_record? ? :false : :true )
95
95
end
96
96
97
- # Returns the class descending directly from ActiveRecord::Base, or
98
- # an abstract class, if any, in the inheritance hierarchy .
97
+ # Returns the first class in the inheritance hierarchy that descends from either an
98
+ # abstract class or from <tt>ActiveRecord::Base</tt> .
99
99
#
100
- # If A extends ActiveRecord::Base, A.base_class will return A. If B descends from A
101
- # through some arbitrarily deep hierarchy, B.base_class will return A.
100
+ # Consider the following behaviour:
102
101
#
103
- # If B < A and C < B and if A is an abstract_class then both B.base_class
104
- # and C.base_class would return B as the answer since A is an abstract_class.
102
+ # class ApplicationRecord < ActiveRecord::Base
103
+ # self.abstract_class = true
104
+ # end
105
+ # class Shape < ApplicationRecord
106
+ # self.abstract_class = true
107
+ # end
108
+ # Polygon = Class.new(Shape)
109
+ # Square = Class.new(Polygon)
110
+ #
111
+ # ApplicationRecord.base_class # => ApplicationRecord
112
+ # Shape.base_class # => Shape
113
+ # Polygon.base_class # => Polygon
114
+ # Square.base_class # => Polygon
105
115
attr_reader :base_class
106
116
107
117
# Returns whether the class is a base class.
0 commit comments