ValueReader that receives a Config whose root is the path being read.
ValueReader that receives a Config whose root is the path being read.
This is generally the most concise way to implement a ValueReader that doesn't depend on the path of the value being read.
For example to read a case class FooBar(foo: Foo, bar: Bar)
, instead of
new ValueReader[FooBar] { def read(config: Config, path: String): FooBar = { val localizedConfig = config.getConfig(path) FooBar( foo = localizedConfig.as[Foo]("foo"), bar = localizedConfig.as[Bar]("bar")) } }
you could do
ValueReader.localized[FooBar] { config => FooBar( foo = config.as[Foo]("foo"), bar = config.as[Bar]("bar)) }