Skip to content

Commit

Permalink
update-key
Browse files Browse the repository at this point in the history
  • Loading branch information
darkleaf committed Jan 20, 2025
1 parent 21e2018 commit 5970136
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 44 deletions.
16 changes: 7 additions & 9 deletions src/darkleaf/di/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -533,19 +533,17 @@
(demolish [_ _])
p/FactoryDescription
(description [_]
{::kind :middleware
:middleware ::update-key
:target-key target
:new-target-key new-key
:f-key f-key
:f f
:arg-keys arg-keys
:args args}))
{::kind :middleware
:middleware ::update-key
:target target
:new-target new-key
:f f-key
:args arg-keys}))
own-keys (cons f-key arg-keys)
own-factories (cons f args)
own-factories (for [factory own-factories]
(u/update-description factory assoc
::update-key-target target))
::update-key {:target target}))
own-registry (zipmap own-keys own-factories)
target-factory (registry target)]
(when (nil? target-factory)
Expand Down
50 changes: 15 additions & 35 deletions test/darkleaf/di/tutorial/x_inspect_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -193,47 +193,27 @@
{:key `a
:dependencies {`a+di-update-key#0-target :optional
`a+di-update-key#0-f :optional
`a+di-update-key#0-arg#0 :optional
`a+di-update-key#0-arg#1 :optional
`a+di-update-key#0-arg#2 :optional}
:description {::di/kind :middleware
:middleware ::di/update-key
:target-key `a
:new-target-key `a+di-update-key#0-target
:f-key `a+di-update-key#0-f
:f str
:arg-keys [`a+di-update-key#0-arg#0
`a+di-update-key#0-arg#1
`a+di-update-key#0-arg#2]
:args ["arg" nil (di/ref `b)]}}
`a+di-update-key#0-arg#0 :optional}
:description {::di/kind :middleware
:middleware ::di/update-key
:target `a
:new-target `a+di-update-key#0-target
:f `a+di-update-key#0-f
:args [`a+di-update-key#0-arg#0]}}
{:key `a+di-update-key#0-target
:description {::di/kind :trivial
:object :obj}}
{:key `a+di-update-key#0-f
:description {::di/kind :trivial
:object str
::di/update-key-target `a}}
:description {::di/kind :trivial
:object str
::di/update-key {:target `a}}}
{:key `a+di-update-key#0-arg#0
:description {::di/kind :trivial
:object "arg"
::di/update-key-target `a}}
{:key `a+di-update-key#0-arg#1
:description {::di/kind :trivial
:object nil
::di/update-key-target `a}}
{:key `a+di-update-key#0-arg#2
:dependencies {`b :required}
:description {::di/kind :ref
:key `b
:type :required
::di/update-key-target `a}}
{:key `b
:description {::di/kind :trivial
:object :b}}]
:description {::di/kind :trivial
:object "arg"
::di/update-key {:target `a}}}]
(di/inspect `a
{`a :obj
`b :b}
(di/update-key `a str "arg" nil (di/ref `b))))))
{`a :obj}
(di/update-key `a str "arg")))))


(t/deftest add-side-dependency-test
Expand Down

0 comments on commit 5970136

Please sign in to comment.