Module: RoadForest::Utility::ClassRegistry::Registrar
- Included in:
- Authorization::AuthenticationChain::Scheme, Resource, SourceRigor::Investigator, TypeHandlers::RDFaWriter::EnvironmentDecorator
- Defined in:
- lib/roadforest/utility/class-registry.rb
Overview
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)
Class Method Summary collapse
Instance Method Summary collapse
- #all_names ⇒ Object
- #get(name) ⇒ Object (also: #[])
- #map_classes(&block) ⇒ Object
- #register(name) ⇒ Object
- #registry ⇒ Object
Class Method Details
.extended(mod) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# 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 |
Instance Method Details
#all_names ⇒ Object
24 25 26 |
# File 'lib/roadforest/utility/class-registry.rb', line 24 def all_names registrar.registry.names end |
#get(name) ⇒ Object Also known as: []
19 20 21 |
# File 'lib/roadforest/utility/class-registry.rb', line 19 def get(name) registrar.registry.get(name) end |
#map_classes(&block) ⇒ Object
28 29 30 |
# File 'lib/roadforest/utility/class-registry.rb', line 28 def map_classes(&block) registrar.map_classes(&block) end |
#register(name) ⇒ Object
15 16 17 |
# File 'lib/roadforest/utility/class-registry.rb', line 15 def register(name) registrar.registry.add(name, self) end |
#registry ⇒ Object
11 12 13 |
# File 'lib/roadforest/utility/class-registry.rb', line 11 def registry @registry ||= ClassRegistry.new(self) end |