Module: Zen::Service::Plugins::Pluggable

Included in:
Zen::Service
Defined in:
lib/zen/service/plugins/pluggable.rb

Defined Under Namespace

Classes: Reflection

Instance Method Summary collapse

Instance Method Details

#pluginsObject Also known as: extensions



36
37
38
# File 'lib/zen/service/plugins/pluggable.rb', line 36

def plugins
  @plugins ||= {}
end

#use(name, **opts, &block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/zen/service/plugins/pluggable.rb', line 6

def use(name, **opts, &block)
  extension = Service::Plugins.fetch(name)

  defaults = extension.config[:default_options]
  opts = defaults.merge(opts) unless defaults.nil?

  if using?(name)
    extension.configure(self, **opts, &block) if extension.respond_to?(:configure)
    return extension
  end

  use_extension(extension, name, **opts, &block)
end

#using?(name) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/zen/service/plugins/pluggable.rb', line 32

def using?(name)
  plugins.key?(name)
end