Sha256: 9afc74d92f8428b64a294b8983d09ba9dc1e15c76d0104b42e60977878bddaa5

Contents?: true

Size: 1.3 KB

Versions: 3

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

require 'dry/system/container'

module Dry
  module System
    module Rails
      # Customized Container class for Rails application
      #
      # @api public
      class Container < System::Container
        setting :auto_register_configs, [], &:dup

        class << self
          # Auto register files from the provided directory
          #
          # @api public
          def auto_register!(dir, &block)
            if block
              config.auto_register_configs << [dir, block]
            else
              config.auto_register << dir
            end

            self
          end

          # @api private
          def finalize!(options = {})
            config.auto_register_configs.each do |(dir, block)|
              auto_registrar.call(dir, &block)
            end
            super
          end

          # Use `require_dependency` to make code reloading work
          #
          # @api private
          def require_path(path)
            require_dependency(path)
          end

          # This is called when reloading in dev mode
          #
          # @api private
          def refresh_boot_files
            booter.boot_files.each do |boot_file|
              load(boot_file)
            end
            self
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dry-system-rails-0.3.1 lib/dry/system/rails/container.rb
dry-system-rails-0.3.0 lib/dry/system/rails/container.rb
dry-system-rails-0.2.0 lib/dry/system/rails/container.rb