Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions source/gems/dry-container/registry-and-resolver.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,18 @@ container.resolve(:key_2) # => "Integer: 282"
You can configure how items are registered and resolved from the container:

```ruby
Dry::Container.configure do |config|
config.registry = ->(container, key, item, options) { container[key] = item }
config.resolver = ->(container, key) { container[key] }
end

class Container
extend Dry::Container::Mixin

configure do |config|
config.registry = ->(container, key, item, options) { container[key] = item }
config.resolver = ->(container, key) { container[key] }
end
registry ->(container, key, item, options) { container[key] = item }
resolver ->(container, key) { container[key] }
end

class ContainerObject
include Dry::Container::Mixin

configure do |config|
config.registry = ->(container, key, item, options) { container[key] = item }
config.resolver = ->(container, key) { container[key] }
end
registry ->(container, key, item, options) { container[key] = item }
resolver ->(container, key) { container[key] }
end
```

Expand Down