require 'dotenv' # Hot Live Constants module HotConstants HOTENV = {} # rubocop:disable Style/MutableConstant LOGGER = SemanticLogger[to_s] class << self def initialize LOGGER.info('initializing') end def stimulus_debug = load_boolean('STIMULUS_DEBUG', false) def log_active_record = load_boolean('LOG_ACTIVE_RECORD', true) def log_action_view = load_boolean('LOG_ACTION_VIEW', true) def reload! HOTENV.replace Dotenv.parse # LOGGER.warn 'reloaded!' ActiveRecord::Base.logger.level = log_active_record ? :debug : :fatal ActionView::Base.logger.level = log_action_view ? :debug : :fatal end private def load_boolean(key, default) = HOTENV.fetch(key, default).to_s.downcase == 'true' end reload! end