Sha256: ecce872b69e07c99b3815892f8614891a4ff4b6739334254c02f2b9417044825

Contents?: true

Size: 1.2 KB

Versions: 4

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

require "dry/rails/railtie"
require "dry/rails/container"
require "dry/rails/components"

module Dry
  # Initializer interface
  #
  # @example set up a container with auto-registration paths
  #   # config/initializer/system.rb
  #
  #   Dry::Rails.container do
  #     auto_register!("lib", "app/operations")
  #   end
  #
  # @see Dry::Rails::Container.auto_register!
  #
  # @api public
  module Rails
    # Set container block that will be evaluated in the context of the container
    #
    # @return [self]
    #
    # @api public
    def self.container(&block)
      _container_blocks << block
      self
    end

    # Create a new container class
    #
    # This is used during booting and reloading
    #
    # @param options [Hash] Container configuration settings
    #
    # @return [Class]
    #
    # @api private
    def self.create_container(options = {})
      Class.new(Container) { config.update(options) }
    end

    # @api private
    def self.evaluate_initializer(container)
      _container_blocks.each do |block|
        container.class_eval(&block)
      end
    end

    # @api private
    def self._container_blocks
      @_container_blocks ||= []
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dry-rails-0.3.0 lib/dry/rails.rb
dry-rails-0.2.1 lib/dry/rails.rb
dry-rails-0.2.0 lib/dry/rails.rb
dry-rails-0.1.0 lib/dry/rails.rb