diff --git a/example_generated_test.go b/example_generated_test.go index 7ded496..2519dbe 100644 --- a/example_generated_test.go +++ b/example_generated_test.go @@ -19,6 +19,7 @@ func ExampleGenerateFromInjectionChain() { return 3 }, nject.GenerateFromInjectionChain( + "example", func(before nject.Collection, after nject.Collection) (nject.Provider, error) { full := before.Append("after", after) inputs, outputs := full.DownFlows() diff --git a/filler_api.go b/filler_api.go index 0793551..bc39916 100644 --- a/filler_api.go +++ b/filler_api.go @@ -33,15 +33,19 @@ type postActionOption struct { // injection chain to replace itself with a regular provider. The ReplaceSelf method will // be called only once. type generatedFromInjectionChain interface { + String() string ReplaceSelf(chainBefore Collection, chainAfter Collection) (selfReplacement Provider, err error) } var _ generatedFromInjectionChain = gfic{} type gfic struct { - f func(chainBefore Collection, chainAfter Collection) (selfReplacement Provider, err error) + name string + f func(chainBefore Collection, chainAfter Collection) (selfReplacement Provider, err error) } +func (g gfic) String() string { return g.name } + func (g gfic) ReplaceSelf(before Collection, after Collection) (selfReplacement Provider, err error) { return g.f(before, after) } @@ -53,9 +57,13 @@ func (g gfic) ReplaceSelf(before Collection, after Collection) (selfReplacement // parameter is a Collection representing all the providers that are later // in the chain from the new special provider. func GenerateFromInjectionChain( + name string, f func(chainBefore Collection, chainAfter Collection) (selfReplacement Provider, err error), ) generatedFromInjectionChain { - return gfic{f} + return gfic{ + name: name, + f: f, + } } type ignore struct{}