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.



15
16
17
18
19
# File 'lib/dry/system/plugins.rb', line 15

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.



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

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.



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

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.



8
9
10
# File 'lib/dry/system/plugins.rb', line 8

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.



22
23
24
25
26
# File 'lib/dry/system/plugins.rb', line 22

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.



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

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.



29
30
31
32
33
34
35
36
37
38
# File 'lib/dry/system/plugins.rb', line 29

def load_dependencies
  Array(dependencies).each do |f|
    begin
      require f unless Plugins.loaded_dependencies.include?(f)
      Plugins.loaded_dependencies << f
    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)


41
42
43
# File 'lib/dry/system/plugins.rb', line 41

def stateful?
  mod < Module
end