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

Convert config to object without needing a key #8

Open
williamho opened this issue Dec 17, 2015 · 3 comments
Open

Convert config to object without needing a key #8

williamho opened this issue Dec 17, 2015 · 3 comments

Comments

@williamho
Copy link

Currently it's not possible to do:

config.as[MyClass]

As a workaround, a dummy key has to be used:

val dummyKey = "dummy-key"
config.atKey(dummyKey).as[MyClass](dummyKey)

ceedubs#10 (comment)

@shanielh
Copy link

shanielh commented May 15, 2016

Actually, I would really like this too.

I guess that the fix is to add another overload to as[X] method that uses this workaround, This won't work with readers that read values using config.getString or other primitives, since you won't be able to get the config in the first place.

We can create implicit values for readers that uses only config.getConfig and get them implicitly in the as[X] overload, so that a compile error will be shown when someone tries to do config.as[String].

update: Thinking about this again, we can add another trait like value reader that has a method read(config: Config), and get that trait implicitly (instead of ValueReader[A]) in config.as[X]

@kailuowang What do you think?

@kailuowang
Copy link
Member

@shanielh that sounds sane to me.

@shanielh
Copy link

@kailuowang Great, I'll send a PR until Tuesday.

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

No branches or pull requests

3 participants