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.



102
103
104
105
106
107
108
109
110
111
# File 'lib/rocket_job/config.rb', line 102

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

  filter                   = where_filter
  (filter ||= {})['_type'] = include_filter if include_filter
  (filter ||= {})['_type'] = {'$not' => exclude_filter} if exclude_filter
  filter
end

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

Configure Mongoid

Raises:

  • (ArgumentError)


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

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)

  # Load Encryption configuration file if present
  return unless defined?(SymmetricEncryption)

  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