-
Notifications
You must be signed in to change notification settings - Fork 74
Description
I love configatron, but although it solves a lot of things, it makes it rather difficult to work with unassigned keys.
In a standard hash, or an OpenStruct, non existing values are falsy:
o = OpenStruct.new({ one: '1', two: '2' })
p o.three
# => nilWhile in configatron they are truthy:
# configatron.allow = false # unset
p configatron.allow ? "allowed" : "not allowed"
# => "allowed" (but expected "not allowed")Even if I want to set defaults, I cannot work with the common ruby syntax:
configatron.allow ||= falseAnd instead, I can only do:
configatron.allow = false unless configatron.has_key? :allowAnd in cases where I can't (or prefer to avoid) having defaults, in order to allow "open schema", the only way for me to handle unset keys in the same way as falsy keys, is:
allowed = configatron.has_key?(:allow) ? configatron.allow : false
p allowed ? "allowed" : "not allowed"Am I missing some functionality in configatron that will make this easier?
If there is no way to alleviate the above issues, I would love to see a change that allows it - even if it will require me to opt-in to this behavior using some config directive (in case it is desired to avoid introducing a breaking change).