subcut
subcut copied to clipboard
Added support for config file properties injection
I'm using subcut in some of my projects and I wanted to simplify the use case in which an object needs to retrieve some of the properties from configuration files.
I added some feature to implement injection similarly to the @value annotation in spring. For example:
class ToInject(implicit val bindingModule: BindingModule) extends Injectable {
val stringProperty = injectProperty[String]("property1")
val intProperty = injectProperty[Int]("property2")
val longProperty = injectProperty[Long]("property3")
val floatProperty = injectProperty[Float]("property4")
}
Allowing to inject in this way:
{
implicit val bindingModule = newBindingModuleWithConfig(PropertiesConfigPropertySource.fromPath("src/test/resources/test.properties"))
val configReaderInstance = new ToInject
}
It supports injection of basic types and allows generic types injection if a custom conversion function is provided.
I think it can help in simplify the code a lot. At least is doing it in my current work.
That's cool stuff, like it :+1: