module Dim

Dependency Injection - Minimal (DIM)

The DIM module provides a minimal dependency injection framework for Ruby programs.

Example:

require 'dim'

container = Dim::Container.new
container.register(:log_file) { "logfile.log" }
container.register(:logger) { |c| FileLogger.new(c.log_file) }
container.register(:application) { |c|
  app = Application.new
  app.logger = c.logger
  app
}

c.application.run

Constants

DuplicateServiceError

Thrown when a duplicate service is registered.

EnvironmentVariableNotFound

Thrown by register_env when a suitable ENV variable can’t be found

MissingServiceError

Thrown when a service cannot be located by name.

VERSION