Sha256: 2adf97255364c0ecc1ace03477cfe4b35c5c08825e234fc701bcd87f6ec3ccb0

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 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.setting :ignored_dependencies, []

          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/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.13.1 lib/dry/system/plugins/dependency_graph.rb
dry-system-0.13.0 lib/dry/system/plugins/dependency_graph.rb