Sha256: cb51eecf7c854e311f91c470f3e2a371bbaed164f8cd5e7808a366c4ec7ed8a4

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

require 'dry/system/constants'
require 'dry/system/plugins/dependency_graph/strategies'

module Dry
  module System
    module Plugins
      # @api public
      module DependencyGraph
        # @api private
        def self.extended(system)
          super

          system.use(:notifications)

          system.before(:configure) do
            setting :ignored_dependencies, []
          end

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

            strategies(Strategies)
          end
        end

        # @api private
        def self.dependencies
          { 'dry-events': 'dry/events/publisher' }
        end

        # @api private
        def register(key, contents = nil, options = {}, &block)
          super

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

          self
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dry-system-0.17.0 lib/dry/system/plugins/dependency_graph.rb
dry-system-0.15.0 lib/dry/system/plugins/dependency_graph.rb