module NRSER::Meta::ClassAttrs
Mixin to provide methods to define and access class attributes - variables that act like instance variables with regards to inheritance but for the class itself.
The motivation is to create a easy-to-use class instance variables that resolve like regular instance variables by looking up the inheritance hierarchy - meaning that:
-
When the value is set, it is set on the class in which the operation happens.
-
That value is read for that class and any subclasses.
-
Class 'self' attr_accessor values are not visible to subclasses.
-
-
But that value is not visible to any classes further up the inheritance chain.
-
Class variables (`@@` variables) are global to the *entire class hierarchy* rooted at the definition point.
-
The tests in `spec/nrser/class_attrs_spec.rb` provide detailed walk-through of usage and differences from other approaches.
Public Class Methods
Extend the including class with {NRSER::Meta::ClassAttrs::ClassMethods}
# File lib/nrser/meta/class_attrs.rb, line 116 def self.included base base.extend ClassMethods end