Class: RocketJob::Config

Inherits:
Object
  • Object
show all
Includes:
SemanticLogger::Loggable
Defined in:
lib/rocket_job/config.rb

Overview

Rocket Job Configuration

Class Method Summary collapse

Class Method Details

.filterObject

Returns [Hash] the where clause built from the filters above:

include_filter, exclude_filter, and where_filter.

Returns nil if no filter should be applied.

Raises:

  • (ArgumentError)


100
101
102
103
104
105
106
107
# File 'lib/rocket_job/config.rb', line 100

def self.filter
  raise(ArgumentError, "Cannot supply both an include_filter and an exclude_filter") if include_filter && exclude_filter

  filter                   = where_filter
  (filter ||= {})["_type"] = include_filter if include_filter
  (filter ||= {})["_type"] = {"$not" => exclude_filter} if exclude_filter
  filter&.dup
end

.load!(environment = "development", file_name = nil, encryption_file_name = nil) ⇒ Object

Configure Mongoid

Raises:

  • (ArgumentError)


76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/rocket_job/config.rb', line 76

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")

  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)

  config_file =
    if encryption_file_name
      Pathname.new(encryption_file_name)
    else
      Pathname.pwd.join("config/symmetric-encryption.yml")
    end

  return unless config_file.file?

  logger.debug "Reading SymmetricEncryption configuration from: #{config_file}"
  SymmetricEncryption.load!(config_file.to_s, environment)
end