You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
782 B
31 lines
782 B
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
|