Class: Dry::System::Plugins::Plugin Private

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/system/plugins.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, mod, &block) ⇒ Plugin

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Plugin.



17
18
19
20
21
# File 'lib/dry/system/plugins.rb', line 17

def initialize(name, mod, &block)
  @name = name
  @mod = mod
  @block = block
end

Instance Attribute Details

#blockObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



14
15
16
# File 'lib/dry/system/plugins.rb', line 14

def block
  @block
end

#modObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
# File 'lib/dry/system/plugins.rb', line 12

def mod
  @mod
end

#nameObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
# File 'lib/dry/system/plugins.rb', line 10

def name
  @name
end

Instance Method Details

#apply_to(system, options) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
27
28
# File 'lib/dry/system/plugins.rb', line 24

def apply_to(system, options)
  system.extend(stateful? ? mod.new(options) : mod)
  system.instance_eval(&block) if block
  system
end

#dependenciesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



50
51
52
# File 'lib/dry/system/plugins.rb', line 50

def dependencies
  mod.respond_to?(:dependencies) ? Array(mod.dependencies) : EMPTY_ARRAY
end

#load_dependenciesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/dry/system/plugins.rb', line 31

def load_dependencies
  Array(dependencies).each do |f|
    begin
      next if Plugins.loaded_dependencies.include?(f.to_s)

      require f
      Plugins.loaded_dependencies << f.to_s
    rescue LoadError => e
      raise PluginDependencyMissing.new(name, e.message)
    end
  end
end

#stateful?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


45
46
47
# File 'lib/dry/system/plugins.rb', line 45

def stateful?
  mod < Module
end