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