Class: Droonga::LegacyPluginRepository
- Inherits:
-
Object
- Object
- Droonga::LegacyPluginRepository
- Includes:
- Enumerable
- Defined in:
- lib/droonga/legacy_plugin_repository.rb
Instance Method Summary collapse
- #[](name) ⇒ Object
- #clear ⇒ Object
- #each(&block) ⇒ Object
-
#initialize ⇒ LegacyPluginRepository
constructor
A new instance of LegacyPluginRepository.
- #instantiate(name, *args, &block) ⇒ Object
- #register(name, klass) ⇒ Object
Constructor Details
#initialize ⇒ LegacyPluginRepository
Returns a new instance of LegacyPluginRepository.
20 21 22 |
# File 'lib/droonga/legacy_plugin_repository.rb', line 20 def initialize @plugins = {} end |
Instance Method Details
#[](name) ⇒ Object
32 33 34 |
# File 'lib/droonga/legacy_plugin_repository.rb', line 32 def [](name) @plugins[name] end |
#clear ⇒ Object
36 37 38 |
# File 'lib/droonga/legacy_plugin_repository.rb', line 36 def clear @plugins.clear end |
#each(&block) ⇒ Object
24 25 26 |
# File 'lib/droonga/legacy_plugin_repository.rb', line 24 def each(&block) @plugins.each(&block) end |
#instantiate(name, *args, &block) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/droonga/legacy_plugin_repository.rb', line 40 def instantiate(name, *args, &block) plugin_class = self[name] if plugin_class.nil? # TODO: use the original error raise ArgumentError, "unknown plugin: <#{name}>" end begin plugin_class.new(*args, &block) rescue p [plugin_class, plugin_class.method(:new), plugin_class.method(:new).arity, args.size] raise end end |
#register(name, klass) ⇒ Object
28 29 30 |
# File 'lib/droonga/legacy_plugin_repository.rb', line 28 def register(name, klass) @plugins[name] = klass end |