Closed gausby closed 5 years ago
In my head I had assumed that users could use whichever coercion function they needed for any given key. So
Config.get_int("key")
Config.get_string("key")
Config.get_bool("key")
Would all be valid uses. That said I think that passing the "coercion method" as an argument could be useful and could theoretically be extended to allow users to pass in functions if they needed custom coercion methods like so:
Config.get("key", as: fn (value) -> my_custom_coercion(value) end)
I ended up going with this design. Thanks for the suggestion :+1:
The calls of this form:
Wouldn't it be more extensible, and cleaner to say:
That way one could make their own data coercers that coerced the value into something that makes sense for their application. Just a thought.