Class: Dry::Rails::Container

Inherits:
System::Container
  • Object
show all
Defined in:
lib/dry/rails/container.rb

Overview

Customized Container class for Rails applications

Configuration collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.config.auto_inject_constant=(auto_inject_constant) ⇒ Object

Set a custom import constant name



39
40
41
# File 'lib/dry/rails/container.rb', line 39

setting :auto_inject_constant,
default: "Deps",
reader: true

.config.container_constant=(container_constant) ⇒ Object

Set a custom container constant



50
51
52
# File 'lib/dry/rails/container.rb', line 50

setting :container_constant,
default: "Container",
reader: true

.config.features=(features) ⇒ Object

Set an array of features that should be enabled by default

Available values are:

  • application_contract
  • safe_params
  • controller_helpers


28
29
30
# File 'lib/dry/rails/container.rb', line 28

setting :features,
default: i[application_contract safe_params controller_helpers],
reader: true

.refresh_provider_filesself

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This is called when reloading in dev mode



82
83
84
85
86
87
# File 'lib/dry/rails/container.rb', line 82

def refresh_provider_files
  providers.provider_files.each do |boot_file|
    ::Kernel.load(boot_file)
  end
  self
end

.started?(name) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return if a given component was started



65
66
67
# File 'lib/dry/rails/container.rb', line 65

def started?(name)
  providers[name].started?
end

Instance Method Details

#require_path(path) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



72
73
74
# File 'lib/dry/rails/container.rb', line 72

def require_path(path)
  require_dependency(path)
end