eed3si9n / treehugger

treehugger.scala is a library to code Scala programmatically.
http://eed3si9n.com/treehugger
Other
133 stars 20 forks source link

Unable to generate a Play WS client class #36

Open fralken opened 8 years ago

fralken commented 8 years ago

I'd like to generate a class for Play client like so

class PetStoreClient @Inject() (WS: WSClient) (baseUrl: String) {

but it is not possible:

Thanks

tmkontra commented 5 years ago

Not sure if this entirely solves the issue, but I found a possible work-around:

val myClassName = "PetStoreClient"
CLASSDEF(
      myClassName + " @Inject()"
)

returns

class PetStoreClient @Inject()

this doesn't have great ergonomics on multiple param lists, but if you can turn all N-1 parameter lists to their strings and jam them in the "class name" like above, then you can still formulate the final (N) parameter list via .withParams

I'm hoping to look in to adding these functionalities after I get more familiar with the library (Play integration is my use case as well, as I am sure is the case for many others due to its popularity).