Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inspect with meta #28

Open
darkleaf opened this issue Oct 28, 2024 · 0 comments · May be fixed by #33
Open

Inspect with meta #28

darkleaf opened this issue Oct 28, 2024 · 0 comments · May be fixed by #33

Comments

@darkleaf
Copy link
Owner

darkleaf commented Oct 28, 2024

We could add a middleware metadata to the component info.

diff --git a/src/darkleaf/di/core.clj b/src/darkleaf/di/core.clj
index 2b810bc..0e6462a 100644
--- a/src/darkleaf/di/core.clj
+++ b/src/darkleaf/di/core.clj
@@ -526,6 +526,7 @@
                                    args (map deps arg-keys)]
                                (apply f t args)))
                            (demolish [_ _]))
+          new-factory (with-meta new-factory {:type ::update-key})
           own-registry   (zipmap (cons f-key arg-keys)
                                  (cons f     args))
           target-factory (registry target)]
@@ -840,7 +841,8 @@
             info          (into {}
                                 (filter (fn [[k v]] (some? v)))
                                 {:key          key
-                                 :dependencies declared-deps})]
+                                 :dependencies declared-deps
+                                 :meta         (meta factory)})]
         (reify p/Factory
           (dependencies [_]
             declared-deps)
diff --git a/test/darkleaf/di/tutorial/x_inspect_test.clj b/test/darkleaf/di/tutorial/x_inspect_test.clj
index f8b69fd..143209f 100644
--- a/test/darkleaf/di/tutorial/x_inspect_test.clj
+++ b/test/darkleaf/di/tutorial/x_inspect_test.clj
@@ -18,4 +18,4 @@
   (t/is (= [{:key `c :dependencies {`a :required `b :optional}}
             {:key `a}
             {:key `b :dependencies {`a :required}}]
-           (di/inspect `c))))
+           (di/inspect `c (di/update-key `a str)))))
@darkleaf darkleaf linked a pull request Nov 9, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant