Sha256: 33fb3056d81f96e5b5e985a3e6c18c15afb38066fd3fe20f3a72b9a6f0ed97b9
Contents?: true
Size: 718 Bytes
Versions: 2
Compression:
Stored size: 718 Bytes
Contents
= Registerable Require the library. require 'mixers/registerable' Registerable can be used directly. module MyStuff extend Registerable end MyStuff.register(10, :x) Then the MyStuff registry will contain 10 indexed by :x. MyStuff.registry[:x].assert == 10 Registrable can also be used as a base class callback to track subclasses. class Abstract extend Registerable def self.inherited(base) register(base, base.name.split('::').last.downcase) end end Now when we inherit from Abstract, the subclass will be automatically registered. class Example < Abstract end We see that the class is in the Abstract registry. Abstract.registry['example'].assert == Example
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mixers-1.2.0 | qed/10_registerable.rdoc |
mixers-1.1.0 | qed/10_registerable.rdoc |