lib/rrj/tools/bin/environment.rb in ruby_rabbitmq_janus-2.6.0.pre.244 vs lib/rrj/tools/bin/environment.rb in ruby_rabbitmq_janus-2.6.0.pre.246
- old
+ new
@@ -1,11 +1,19 @@
# frozen_string_literal: true
# Load environment variables for execute correctly `Binary` class
-ENVIRONMENT = ENV['RAILS_ENV']
-ORM = ENV['ORM']
-LISTENER_PATH = ENV['LISTENER_PATH']
-PROGRAM = ENV['PROGRAM_NAME']
+def blank?(value)
+ value.eql?('') || value.nil?
+end
+
+def check_variable(name)
+ blank?(ENV[name]) ? raise(NameError) : ENV[name]
+end
+
+ENVIRONMENT = check_variable('RAILS_ENV')
+ORM = check_variable('ORM')
+LISTENER_PATH = check_variable('LISTENER_PATH')
+PROGRAM = check_variable('PROGRAM_NAME')
@verbose = false
@logger_class = true