Module: Rigor::Plugin

Defined in:
lib/rigor/plugin.rb,
lib/rigor/plugin/base.rb,
lib/rigor/plugin/loader.rb,
lib/rigor/plugin/manifest.rb,
lib/rigor/plugin/registry.rb,
lib/rigor/plugin/services.rb,
lib/rigor/plugin/load_error.rb,
lib/rigor/plugin/io_boundary.rb,
lib/rigor/plugin/trust_policy.rb,
lib/rigor/plugin/access_denied_error.rb

Defined Under Namespace

Classes: AccessDeniedError, Base, IoBoundary, LoadError, Loader, Manifest, Registry, Services, TrustPolicy

Class Method Summary collapse

Class Method Details

.register(plugin_class) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rigor/plugin.rb', line 18

def register(plugin_class)
  unless plugin_class.is_a?(Class) && plugin_class < Base
    raise ArgumentError,
          "Rigor::Plugin.register expects a subclass of Rigor::Plugin::Base, got #{plugin_class.inspect}"
  end

  manifest = plugin_class.manifest # rigor:disable undefined-method
  @mutex.synchronize do
    existing = @registered[manifest.id]
    if existing && existing != plugin_class
      raise LoadError.new(
        "plugin id #{manifest.id.inspect} already registered to #{existing}, " \
        "cannot re-register to #{plugin_class}",
        plugin_ref: manifest.id
      )
    end

    @registered[manifest.id] = plugin_class
  end
  plugin_class
end

.registeredObject



44
45
46
# File 'lib/rigor/plugin.rb', line 44

def registered
  @mutex.synchronize { @registered.dup.freeze }
end

.registered_for(id) ⇒ Object



40
41
42
# File 'lib/rigor/plugin.rb', line 40

def registered_for(id)
  @mutex.synchronize { @registered[id.to_s] }
end

.unregister!(id = nil) ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'lib/rigor/plugin.rb', line 48

def unregister!(id = nil)
  @mutex.synchronize do
    if id.nil?
      @registered.clear
    else
      @registered.delete(id.to_s)
    end
  end
end