Class: Kuby::PluginRegistry

Inherits:
Object
  • Object
show all
Defined in:
lib/kuby/plugin_registry.rb

Constant Summary collapse

ANY =
'any'.freeze

Instance Method Summary collapse

Instance Method Details

#find(plugin_name, environment: Kuby.env) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/kuby/plugin_registry.rb', line 11

def find(plugin_name, environment: Kuby.env)
  plugins_by_env = plugins[plugin_name]

  unless plugins_by_env
    raise Kubernetes::MissingPluginError, "no plugin registered with name #{plugin_name}, "\
      'do you need to add a gem to your Gemfile?'
  end

  plugins_by_env[environment] || plugins_by_env[ANY]
end

#register(plugin_name, plugin_klass, environment: ANY) ⇒ Object



6
7
8
9
# File 'lib/kuby/plugin_registry.rb', line 6

def register(plugin_name, plugin_klass, environment: ANY)
  plugins[plugin_name] ||= {}
  plugins[plugin_name][environment] ||= plugin_klass
end