Skip to content
This repository has been archived by the owner on Oct 19, 2021. It is now read-only.

add convenience extension function #6

Open
dtanner opened this issue Nov 25, 2019 · 0 comments
Open

add convenience extension function #6

dtanner opened this issue Nov 25, 2019 · 0 comments

Comments

@dtanner
Copy link
Owner

dtanner commented Nov 25, 2019

fun <T> T.withEnvOverrides(prefix: String, defaults: (T.() -> Unit)? = null): T {
    val config = this

    defaults?.invoke(config)
    return EnvConfigLoader.overrideFromEnvironment(config, prefix)
}

sample usage:

val metricsConfig = MetricsConfig().withEnvOverrides("METRICS")
bind(MetricsConfig::class.java).toInstance(metricsConfig)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant