Class: RocketJob::Config
- Inherits:
-
Object
- Object
- RocketJob::Config
- Includes:
- Plugins::Document
- Defined in:
- lib/rocket_job/config.rb
Overview
Centralized Configuration for Rocket Jobs
Class Method Summary collapse
-
.instance ⇒ Object
Returns the single instance of the Rocket Job Configuration for this site in a thread-safe way.
-
.load!(environment = 'development', file_name = nil, encryption_file_name = nil) ⇒ Object
Configure Mongoid.
Class Method Details
.instance ⇒ Object
Returns the single instance of the Rocket Job Configuration for this site in a thread-safe way
9 10 11 12 13 14 15 16 |
# File 'lib/rocket_job/config.rb', line 9 def self.instance @@instance ||= begin first || create rescue StandardError # In case another process has already created the first document first end end |
.load!(environment = 'development', file_name = nil, encryption_file_name = nil) ⇒ Object
Configure Mongoid
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/rocket_job/config.rb', line 52 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 # 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) end end end |