Module: Stockboy::Registry
- Included in:
- Filters, Providers, Readers, Translations
- Defined in:
- lib/stockboy/registry.rb
Overview
Holds a collection of registered classes for convenient reference by symbolic name
Instance Method Summary collapse
-
#all ⇒ Hash
List all named classes in the registry.
- #build(key, options, block) ⇒ Object
-
#find(key) ⇒ Class
(also: #[])
Look up a class and return it by symbolic name.
-
#register(key, provider) ⇒ Object
Register a class under a convenient symbolic name.
Instance Method Details
#all ⇒ Hash
List all named classes in the registry
37 38 39 |
# File 'lib/stockboy/registry.rb', line 37 def all @registry end |
#build(key, options, block) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/stockboy/registry.rb', line 41 def build(key, , block) = [] unless .is_a? Array key = find(key) if key.is_a? Symbol key = key.new(*, &block) if key.is_a? Class key end |
#find(key) ⇒ Class Also known as: []
Look up a class and return it by symbolic name
28 29 30 |
# File 'lib/stockboy/registry.rb', line 28 def find(key) @registry[key] end |
#register(key, provider) ⇒ Object
Register a class under a convenient symbolic name
19 20 21 |
# File 'lib/stockboy/registry.rb', line 19 def register(key, provider) @registry[key] = provider end |