Module: Dry::Rails

Defined in:
lib/dry/rails.rb,
lib/dry/rails/railtie.rb,
lib/dry/rails/version.rb,
lib/dry/rails/container.rb,
lib/dry/rails/auto_registrars/app.rb,
lib/dry/rails/features/safe_params.rb,
lib/dry/rails/features/controller_helpers.rb,
lib/dry/rails/features/application_contract.rb

Overview

Initializer interface

Examples:

set up a container with auto-registration paths

# config/initializer/system.rb

Dry::Rails.container do
  config.component_dirs.add "lib" do |dir|
    dir.namespaces.add "my_super_cool_app", key: nil
  end

  config.component_dirs.add "app/operations"
end

Defined Under Namespace

Modules: AutoRegistrars, Features Classes: Container, Railtie

Constant Summary collapse

VERSION =
"0.7.0"

Class Method Summary collapse

Class Method Details

._container_blocksObject

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.



56
57
58
# File 'lib/dry/rails.rb', line 56

def self._container_blocks
  @_container_blocks ||= []
end

.container(&block) ⇒ self

Set container block that will be evaluated in the context of the container

Returns:

  • (self)


30
31
32
33
# File 'lib/dry/rails.rb', line 30

def self.container(&block)
  _container_blocks << block
  self
end

.create_container(options = {}) ⇒ Class

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.

Create a new container class

This is used during booting and reloading

Parameters:

  • options (Hash) (defaults to: {})

    Container configuration settings

Returns:

  • (Class)


44
45
46
# File 'lib/dry/rails.rb', line 44

def self.create_container(options = {})
  Class.new(Container) { config.update(options) }
end

.evaluate_initializer(container) ⇒ 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.



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

def self.evaluate_initializer(container)
  _container_blocks.each do |block|
    container.class_eval(&block)
  end
end