Skip to content

Commit

Permalink
Rename membersOf to autowireMembersOf (#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamw authored Sep 16, 2024
1 parent ea3de81 commit 4a8812b
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ of the default construct/`apply` mechanism. These are described in detail below.
* an instance to use
* a function to create an instance
* a class to instantiate to provide a dependency for the types it implements (provided as: `classOf[SomeType]`)
* a `membersOf(instance)` call, to use the members of the given instance as dependencies
* a `autowireMembersOf(instance)` call, to use the members of the given instance as dependencies

`autowire` is context-free: its result does not depend on the environment, within which it is called (except for
implicit parameters, which are looked up using the usual mechanism). It only depends on the type that is specified
Expand Down Expand Up @@ -183,7 +183,7 @@ Without the `classOf[]`, MacWire wouldn't know how to create an instance impleme

## Using dependencies contained in objects

Finally, it's possible to use the members of a given instance as dependencies. Simply pass a `memberOf(someInstance)`
Finally, it's possible to use the members of a given instance as dependencies. Simply pass a `autowireMembersOf(someInstance)`
as a parameter to `autowire`.

## Errors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class AutowireProviders[Q <: Quotes](using val q: Q)(
else Vector.empty

val membersOfProviders =
if term.show.startsWith("com.softwaremill.macwire.macwire$package.membersOf") then
if term.show.startsWith("com.softwaremill.macwire.macwire$package.autowireMembersOf") then
providersFromMembersOf(term)
else Vector.empty

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import com.softwaremill.macwire.internals.MacwireMacros
* - an instance to use
* - a function to create an instance
* - a class to instantiate to provide a dependency for the types it implements (provided as: `classOf[SomeType]`)
* - a `membersOf(instance)` call, to use the members of the given instance as dependencies
* - a `autowireMembersOf(instance)` call, to use the members of the given instance as dependencies
*
* Any missing dependenciess will be created using the publicly available primary constructors or apply methods.
*
Expand Down Expand Up @@ -113,4 +113,4 @@ inline def wireRec[T]: T = ${ MacwireMacros.wireRecImpl[T] }
/** Marker method to be used in [[autowire]], to specify that values defined in the given value should be used for
* wiring.
*/
def membersOf[T](t: T): T = ???
def autowireMembersOf[T](t: T): T = ???
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Deps(val a: A, b: B):
case class C(a: A, b: B)

val d = new Deps(new A {}, new B {})
val c = autowire[C](membersOf(d))
val c = autowire[C](autowireMembersOf(d))

assert(c.a eq d.a)
assert(c.b eq d.bb)
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ class Deps(val a: A, b: B):
case class C(a: A, b: B)

val d = new Deps(new A, new B)
autowire[C](membersOf(d), new A)
autowire[C](autowireMembersOf(d), new A)
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ class AutowireCompileTests extends CompileTestsSupport:
"cannot find a provided dependency, public constructor or public apply method for: A;",
"wiring path: B -> A"
),
"membersOfDuplicate" -> List("duplicate type in dependencies list: A, for: new A()")
"autowireMembersOfDuplicate" -> List("duplicate type in dependencies list: A, for: new A()")
)
)

0 comments on commit 4a8812b

Please sign in to comment.