Module: ActiveFedora::Inheritance::ClassMethods
- Defined in:
- lib/active_fedora/inheritance.rb
Instance Method Summary collapse
-
#abstract_class? ⇒ Boolean
Abstract classes can’t have default scopes.
-
#base_class ⇒ Object
Returns the class descending directly from ActiveFedora::Base, or an abstract class, if any, in the inheritance hierarchy.
Instance Method Details
#abstract_class? ⇒ Boolean
Abstract classes can’t have default scopes.
27 28 29 |
# File 'lib/active_fedora/inheritance.rb', line 27 def abstract_class? self == Base end |
#base_class ⇒ Object
Returns the class descending directly from ActiveFedora::Base, or an abstract class, if any, in the inheritance hierarchy.
If A extends ActiveFedora::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.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/active_fedora/inheritance.rb', line 14 def base_class return File if self <= File raise ActiveFedoraError, "#{name} doesn't belong in a hierarchy descending from ActiveFedora" unless self <= Base if self == Base || superclass == Base || superclass.abstract_class? self else superclass.base_class end end |