lib/rocket_job/config.rb in rocketjob-3.4.3 vs lib/rocket_job/config.rb in rocketjob-3.5.0

- old
+ new

@@ -49,24 +49,28 @@ field :re_check_seconds, type: Integer, default: 60 # Configure Mongoid def self.load!(environment = 'development', file_name = nil, encryption_file_name = nil) config_file = file_name ? Pathname.new(file_name) : Pathname.pwd.join('config/mongoid.yml') - if config_file.file? - logger.debug "Reading Mongo configuration from: #{config_file}" - Mongoid.load!(config_file, environment) - else - raise(ArgumentError, "Mongo Configuration file: #{config_file.to_s} not found") - end + raise(ArgumentError, "Mongo Configuration file: #{config_file} not found") unless config_file.file? + + logger.debug "Reading Mongo configuration from: #{config_file}" + Mongoid.load!(config_file, environment) + # Load Encryption configuration file if present - if defined?(SymmetricEncryption) - config_file = encryption_file_name ? Pathname.new(encryption_file_name) : Pathname.pwd.join('config/symmetric-encryption.yml') - if config_file.file? - logger.debug "Reading SymmetricEncryption configuration from: #{config_file}" - SymmetricEncryption.load!(config_file.to_s, environment) + return unless defined?(SymmetricEncryption) + + config_file = + if encryption_file_name + Pathname.new(encryption_file_name) + else + Pathname.pwd.join('config/symmetric-encryption.yml') end - end - end + return unless config_file.file? + + logger.debug "Reading SymmetricEncryption configuration from: #{config_file}" + SymmetricEncryption.load!(config_file.to_s, environment) + end end end