Class: Yao::Plugins::Registry
- Inherits:
-
Object
- Object
- Yao::Plugins::Registry
- Includes:
- Singleton
- Defined in:
- lib/yao/plugins/registry.rb
Instance Method Summary collapse
- #[](type) ⇒ Object
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
- #register(klass, type: nil, name: :default) ⇒ Object
Constructor Details
#initialize ⇒ Registry
Returns a new instance of Registry.
7 8 9 |
# File 'lib/yao/plugins/registry.rb', line 7 def initialize @types = {} end |
Instance Method Details
#[](type) ⇒ Object
11 12 13 |
# File 'lib/yao/plugins/registry.rb', line 11 def [](type) @types[type] end |
#register(klass, type: nil, name: :default) ⇒ Object
15 16 17 18 19 |
# File 'lib/yao/plugins/registry.rb', line 15 def register(klass, type: nil, name: :default) raise("Plugin registration requires both type and name.") if !type or !name @types[type] ||= {} @types[type][name] = klass end |