Sha256: f4401d9a15220c22440e7fa6ad2885b6131d129b1ca8f62d979a11b217573ffc

Contents?: true

Size: 1.08 KB

Versions: 10

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module Dry
  module System
    class AutoRegistrar
      # Default auto_registrar configuration
      #
      # This is currently configured by default for every System::Container.
      # Configuration allows to define custom initialization as well as exclusion
      # logic, for each component that is being registered by Dry::System
      # auto-registration.
      #
      # @api private
      class Configuration
        DEFAULT_INSTANCE = -> component { component.instance }.freeze
        FALSE_PROC = -> * { false }.freeze

        def self.setting(name)
          define_method(name) do |&block|
            ivar = "@#{name}"
            if block
              instance_variable_set(ivar, block)
            else
              instance_variable_get(ivar)
            end
          end
        end

        setting :exclude
        setting :instance

        attr_accessor :memoize

        # @api private
        def initialize
          @instance = DEFAULT_INSTANCE
          @exclude = FALSE_PROC
          @memoize = false
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
dry-system-0.18.2 lib/dry/system/auto_registrar/configuration.rb
dry-system-0.18.1 lib/dry/system/auto_registrar/configuration.rb
dry-system-0.18.0 lib/dry/system/auto_registrar/configuration.rb
dry-system-0.17.0 lib/dry/system/auto_registrar/configuration.rb
dry-system-0.15.0 lib/dry/system/auto_registrar/configuration.rb
dry-system-0.14.1 lib/dry/system/auto_registrar/configuration.rb
dry-system-0.14.0 lib/dry/system/auto_registrar/configuration.rb
dry-system-0.13.2 lib/dry/system/auto_registrar/configuration.rb
dry-system-0.13.1 lib/dry/system/auto_registrar/configuration.rb
dry-system-0.13.0 lib/dry/system/auto_registrar/configuration.rb