Module: Dry::System::Plugins::DependencyGraph

Defined in:
lib/dry/system/plugins/dependency_graph.rb,
lib/dry/system/plugins/dependency_graph/strategies.rb

Defined Under Namespace

Classes: Strategies

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.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.



27
28
29
# File 'lib/dry/system/plugins/dependency_graph.rb', line 27

def self.dependencies
  {"dry-events" => "dry/events/publisher"}
end

.extended(system) ⇒ 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.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/dry/system/plugins/dependency_graph.rb', line 9

def self.extended(system)
  super

  system.instance_eval do
    use(:notifications)

    setting :dependency_graph do
      setting :ignored_dependencies, default: []
    end

    after(:configure) do
      self[:notifications].register_event(:resolved_dependency)
      self[:notifications].register_event(:registered_dependency)
    end
  end
end

Instance Method Details

#injector(**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.



32
33
34
# File 'lib/dry/system/plugins/dependency_graph.rb', line 32

def injector(**options)
  super(**options, strategies: DependencyGraph::Strategies)
end

#register(key, contents = nil, options = {}, &block) ⇒ 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.



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/dry/system/plugins/dependency_graph.rb', line 37

def register(key, contents = nil, options = {}, &block)
  super.tap do
    key = key.to_s

    unless config.dependency_graph.ignored_dependencies.include?(key)
      self[:notifications].instrument(
        :registered_dependency,
        key: key,
        class: self[key].class
      )
    end
  end
end