based on this suggestion here from @smudge #34 (comment)
I wonder if in some earlier routine it would make sense to do something like this:
def set_defaults!
if Webvalve.env.in?(ALWAYS_ENABLED_ENVS)
if ENV.key? 'WEBVALVE_SERVICE_ENABLED_DEFAULT'
WebValve.logger.warn SERVICE_ENABLED_DEFAULT_WARNING
end
if ENV.key? 'WEBVALVE_ENABLED'
WebValve.logger.warn WEBVALVE_ENABLED_WARNING
end
ENV['WEBVALVE_ENABLED'] = '1'
ENV['WEBVALVE_SERVICE_ENABLED_DEFAULT'] = '0'
else
ENV['WEBVALVE_ENABLED'] ||= '0'
ENV['WEBVALVE_SERVICE_ENABLED_DEFAULT'] ||= '1'
end
end
And then inside of Manager there doesn't need to be a concept of "always" or "explicit" - it can more naively trust that the two ENV vars are set and mean what they say they mean:
def enabled?
ENABLED_VALUES.include?(ENV.fetch('WEBVALVE_ENABLED'))
end
def services_enabled_by_default?
ENABLED_VALUES.include?(ENV.fetch('WEBVALVE_SERVICE_ENABLED_DEFAULT'))
end
def allowing?
enabled? && services_enabled_by_default?
end
def intercepting?
enabled? && !services_enabled_by_default?
end
based on this suggestion here from @smudge #34 (comment)
I wonder if in some earlier routine it would make sense to do something like this:
And then inside of
Managerthere doesn't need to be a concept of "always" or "explicit" - it can more naively trust that the two ENV vars are set and mean what they say they mean: