Sha256: f3c07effb08f2191d04233af0a39d20762183733a62f3ce224b61c395b4b0520

Contents?: true

Size: 1.33 KB

Versions: 6

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

require_relative "dependency_graph/strategies"

module Dry
  module System
    module Plugins
      # @api public
      module DependencyGraph
        # @api private
        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

        # @api private
        def self.dependencies
          {"dry-events" => "dry/events/publisher"}
        end

        # @api private
        def injector(**options)
          super(**options, strategies: DependencyGraph::Strategies)
        end

        # @api private
        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
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dry-system-0.27.1 lib/dry/system/plugins/dependency_graph.rb
dry-system-0.27.0 lib/dry/system/plugins/dependency_graph.rb
dry-system-0.26.0 lib/dry/system/plugins/dependency_graph.rb
dry-system-0.25.0 lib/dry/system/plugins/dependency_graph.rb
dry-system-0.24.0 lib/dry/system/plugins/dependency_graph.rb
dry-system-0.23.0 lib/dry/system/plugins/dependency_graph.rb