Default value when querying property
Closed this issue · 3 comments
Current Problem
Is there a way to supply a default value when querying a property?
e.g. in the way that ENV.fetch() can be used?
I have somewhat wondered if this could be an anti-pattern, as it scatters defaults across the code where the property is being fetched...
@pmackay firstly, all Chamber settings are just technically hashes, so you can do ::Chamber.env.foo.fetch('bar', 'baz')
just like you would with ENV
.
Secondly, if you wanted defaults in one spot, I would use YAML's anchors to do this in the YAML file itself and not in code.
It's pretty easy to configure defaults for your different namespaces
Let me know if you have any more questions!
Also, sorry for the delay on the reply!
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.