module RoadForest::Utility::ClassRegistry::Registrar
Extend a module with this in order to make it the registrar for a particular purpose. The top of a class heirarchy will make “register” immediately available to subclasses. Otherwise, classes can say Module::registry.add(name, self)
Public Class Methods
extended(mod)
click to toggle source
# File lib/roadforest/utility/class-registry.rb, line 32 def self.extended(mod) ( class << mod; self; end ).instance_exec(mod) do |mod| define_method :registrar do mod end end end
Public Instance Methods
all_names()
click to toggle source
# File lib/roadforest/utility/class-registry.rb, line 24 def all_names registrar.registry.names end
get(name)
click to toggle source
# File lib/roadforest/utility/class-registry.rb, line 19 def get(name) registrar.registry.get(name) end
Also aliased as: []
map_classes(&block)
click to toggle source
# File lib/roadforest/utility/class-registry.rb, line 28 def map_classes(&block) registrar.map_classes(&block) end
register(name)
click to toggle source
# File lib/roadforest/utility/class-registry.rb, line 15 def register(name) registrar.registry.add(name, self) end
registry()
click to toggle source
# File lib/roadforest/utility/class-registry.rb, line 11 def registry @registry ||= ClassRegistry.new(self) end