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.
9 10 11 |
# File 'lib/yao/plugins/registry.rb', line 9 def initialize @types = {} end |
Instance Method Details
#[](type) ⇒ Object
15 16 17 |
# File 'lib/yao/plugins/registry.rb', line 15 def [](type) @types[type] end |
#register(klass, type: nil, name: :default) ⇒ Object
22 23 24 25 26 |
# File 'lib/yao/plugins/registry.rb', line 22 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 |