-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto-inject dependencies into components
By using dry-system's auto_inject feature, we can get rid of the boilerplate code that injects dependencies into components. We create a `SolidusAdmin::Import` constant that can be used to dynamically create readers for each declared dependency. We also register a top level `main_nav_items` dependency to avoid calling a private in nature `.within_namespace` method. [1] - https://dry-rb.org/gems/dry-system/1.0/dependency-auto-injection/
- Loading branch information
1 parent
8150c02
commit bedf820
Showing
5 changed files
with
29 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
require "solidus_admin/container" | ||
|
||
module SolidusAdmin | ||
# Auto-imports container dependencies. | ||
# | ||
# @example | ||
# class Foo | ||
# # Foo.new will have a `#bar` instance method that returns the | ||
# # result of `Container["bar"]`. | ||
# include Import["bar"] | ||
# end | ||
Import = Container.injector | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters