Class: Dry::Container

Inherits:
Object
  • Object
show all
Includes:
Mixin
Defined in:
lib/dry/container.rb,
lib/dry/container/item.rb,
lib/dry/container/stub.rb,
lib/dry/container/error.rb,
lib/dry/container/mixin.rb,
lib/dry/container/version.rb,
lib/dry/container/registry.rb,
lib/dry/container/resolver.rb,
lib/dry/container/namespace.rb,
lib/dry/container/item/factory.rb,
lib/dry/container/item/callable.rb,
lib/dry/container/namespace_dsl.rb,
lib/dry/container/item/memoizable.rb

Overview

Inversion of Control (IoC) container

Examples:


container = Dry::Container.new
container.register(:item, 'item')
container.resolve(:item)
=> 'item'

container.register(:item1, -> { 'item' })
container.resolve(:item1)
=> 'item'

container.register(:item2, -> { 'item' }, call: false)
container.resolve(:item2)
=> #<Proc:0x007f33b169e998@(irb):10 (lambda)>

Defined Under Namespace

Modules: Configuration, Mixin, Stub Classes: Config, Item, Namespace, NamespaceDSL, Registry, Resolver

Constant Summary collapse

Error =
Class.new(StandardError)
KeyError =
Class.new(::KeyError)
PREFIX_NAMESPACE =
lambda do |namespace, key, config|
  [namespace, key].join(config.namespace_separator)
end
EMPTY_HASH =
{}.freeze
VERSION =
"0.11.0"

Method Summary

Methods included from Mixin

#[], #_container, #clone, #decorate, #dup, #each, #each_key, #enable_stubs!, extended, #freeze, #import, included, #key?, #keys, #merge, #namespace, #register, #resolve