Module: Dry::System::Rails

Defined in:
lib/dry/system/rails.rb,
lib/dry/system/rails/railtie.rb,
lib/dry/system/rails/version.rb,
lib/dry/system/rails/container.rb

Overview

Initializer interface

Examples:

set up a customized container

# config/initializer/system.rb

Dry::System::Rails.container do
  use :monitoring

  config.auto_register << 'app/operations'
end

Defined Under Namespace

Classes: Container, Railtie

Constant Summary collapse

VERSION =
'0.3.1'

Class Method Summary collapse

Class Method Details

.container(&block) ⇒ Object

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



24
25
26
27
# File 'lib/dry/system/rails.rb', line 24

def self.container(&block)
  @container_block = block
  self
end

.container_blockObject

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.



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

def self.container_block
  defined?(@container_block) && @container_block
end

.create_container(options = {}) ⇒ 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.

Create a new container class

This is used during booting and reloading



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/dry/system/rails.rb', line 34

def self.create_container(options = {})
  container = Class.new(Container)

  container.class_eval(&@container_block) if container_block

  default_options = {
    root: ::Rails.root,
    system_dir: ::Rails.root.join('config/system'),
  }
  container.config.update(default_options.merge(options))

  container.load_paths!('lib', 'app', 'app/models')

  container
end