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

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
  1. require 'dotenv'
  2. # Hot Live Constants
  3. module HotConstants
  4. HOTENV = {} # rubocop:disable Style/MutableConstant
  5. LOGGER = SemanticLogger[to_s]
  6. class << self
  7. def initialize
  8. LOGGER.info('initializing')
  9. end
  10. def stimulus_debug = load_boolean('STIMULUS_DEBUG', false)
  11. def log_active_record = load_boolean('LOG_ACTIVE_RECORD', true)
  12. def log_action_view = load_boolean('LOG_ACTION_VIEW', true)
  13. def reload!
  14. HOTENV.replace Dotenv.parse
  15. # LOGGER.warn 'reloaded!'
  16. ActiveRecord::Base.logger.level = log_active_record ? :debug : :fatal
  17. ActionView::Base.logger.level = log_action_view ? :debug : :fatal
  18. end
  19. private
  20. def load_boolean(key, default) = HOTENV.fetch(key, default).to_s.downcase == 'true'
  21. end
  22. reload!
  23. end