Method: ActiveEntity::Inheritance::ClassMethods#base_class
- Defined in:
- lib/active_entity/inheritance.rb
#base_class ⇒ Object
Returns the class descending directly from ActiveEntity::Base, or an abstract class, if any, in the inheritance hierarchy.
If A extends ActiveEntity::Base, A.base_class will return A. If B descends from A through some arbitrarily deep hierarchy, B.base_class will return A.
If B < A and C < B and if A is an abstract_class then both B.base_class and C.base_class would return B as the answer since A is an abstract_class.
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/active_entity/inheritance.rb', line 72 def base_class unless self < Base raise ActiveEntityError, "#{name} doesn't belong in a hierarchy descending from ActiveEntity" end if superclass == Base || superclass.abstract_class? self else superclass.base_class end end |