Sha256: aab5f5c77e2f9497a8f002e5b8d719d5147ff117d02297eb3fbb842b89f133db

Contents?: true

Size: 1.28 KB

Versions: 8

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

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

8 entries across 8 versions & 1 rubygems

Version Path
dry-system-1.1.1 lib/dry/system/plugins/dependency_graph.rb
dry-system-1.1.0 lib/dry/system/plugins/dependency_graph.rb
dry-system-1.1.0.beta2 lib/dry/system/plugins/dependency_graph.rb
dry-system-1.1.0.beta1 lib/dry/system/plugins/dependency_graph.rb
dry-system-1.0.1 lib/dry/system/plugins/dependency_graph.rb
dry-system-1.0.0 lib/dry/system/plugins/dependency_graph.rb
dry-system-1.0.0.rc1 lib/dry/system/plugins/dependency_graph.rb
dry-system-0.27.2 lib/dry/system/plugins/dependency_graph.rb