Skip to content
This repository was archived by the owner on Apr 3, 2026. It is now read-only.

rubyunworks/inheritor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Inheritor

Archived. This functionality is available in Ruby Facets as Module#class_inheritor. This repository is preserved for historical reference.

Inheritor provides a means to store and inherit data along the class hierarchy. An inheritor creates two methods, one named after the key that provides a reader, and one named key! which provides the writer.

The most notable feature of Inheritor is that it is dynamic. Unlike other solutions, such as ActiveSupport's class_inheritable_accessor, Inheritor dynamically generates the inherited value whenever the reader is called.

Synopsis

class X
  inheritor :foo, [], :+
end

class Y < X
end

X.foo! << :a
X.foo  #=> [:a]
Y.foo  #=> [:a]

Y.foo! << :b
X.foo  #=> [:a]
Y.foo  #=> [:a, :b]

Copyright

Copyright (c) 2004 Thomas Sawyer

MIT License. See LICENSE file for details.

About

Class-level Inhertiable Variables

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages