Browse Source

kind of global variable

main
pvincent 2 months ago
parent
commit
c4882ed139
  1. 9
      lib/live/definable.rb

9
lib/live/definable.rb

@ -1,7 +1,6 @@
require 'dotenv'
# FIXME: do not use global variable
$definable_thread_group ||= ThreadGroup.new
DEFINABLE_THREAD_GROUP ||= ThreadGroup.new # rubocop:disable Lint/OrAssignmentToConstant
module Live
# offers typed constant defintions with default value, by using lots of introspecting...
@ -85,13 +84,13 @@ module Live
value = typed_value(type, raw_value, default)
definitions[constant] = { type:, default:, value: }
# puts("-- new definition #{constant}:#{definitions[constant]}")
# logger.debug("new definition #{constant}:#{definitions[constant]}")
value
end
def start_listener
$definable_thread_group.list.each(&:kill)
$definable_thread_group.add(Thread.new do
DEFINABLE_THREAD_GROUP.list.each(&:kill)
DEFINABLE_THREAD_GROUP.add(Thread.new do
listener = Listen.to(Rails.root, only: /^\.env\.?/) do
@@class_origin.reload_from_env
rescue StandardError

Loading…
Cancel
Save