Module: Excom::Plugins::Pluggable
- Included in:
- Service
- Defined in:
- lib/excom/plugins/pluggable.rb
Defined Under Namespace
Classes: Reflection
Instance Method Summary collapse
- #plugins ⇒ Object (also: #extensions)
- #use(name, **opts) ⇒ Object
- #using?(name) ⇒ Boolean
Instance Method Details
#plugins ⇒ Object Also known as: extensions
29 30 31 |
# File 'lib/excom/plugins/pluggable.rb', line 29 def plugins @plugins ||= {} end |
#use(name, **opts) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/excom/plugins/pluggable.rb', line 3 def use(name, **opts) extension = Plugins.fetch(name) method = extension.[:use_with] || :include send(method, extension) defaults = extension.[:default_options] opts = defaults.merge(opts) unless defaults.nil? if extension.const_defined?('ClassMethods') extend extension::ClassMethods end if extension.respond_to?(:used) extension.used(self, **opts) end plugins[name] = Reflection.new(extension, opts) extension end |
#using?(name) ⇒ Boolean
25 26 27 |
# File 'lib/excom/plugins/pluggable.rb', line 25 def using?(name) plugins.key?(name) end |