Class: Jobi::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/jobi/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



7
8
9
10
11
12
13
14
# File 'lib/jobi/configuration.rb', line 7

def initialize
  setup_client
  setup_log_config
  setup_logger
  setup_pub_sub_config
  setup_jobs
  rabbitmq
end

Instance Attribute Details

#act_as_consumerObject

Returns the value of attribute act_as_consumer.



3
4
5
# File 'lib/jobi/configuration.rb', line 3

def act_as_consumer
  @act_as_consumer
end

#act_as_publisherObject

Returns the value of attribute act_as_publisher.



3
4
5
# File 'lib/jobi/configuration.rb', line 3

def act_as_publisher
  @act_as_publisher
end

#clientObject (readonly)

Returns the value of attribute client.



5
6
7
# File 'lib/jobi/configuration.rb', line 5

def client
  @client
end

#jobsObject

Returns the value of attribute jobs.



3
4
5
# File 'lib/jobi/configuration.rb', line 3

def jobs
  @jobs
end

#log_fileObject

Returns the value of attribute log_file.



3
4
5
# File 'lib/jobi/configuration.rb', line 3

def log_file
  @log_file
end

#log_levelObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/jobi/configuration.rb', line 16

def log_level
  case @log_level
  when :info
    Logger::INFO
  when :warn
    Logger::WARN
  when :debug
    Logger::DEBUG
  end
end

#loggerObject (readonly)

Returns the value of attribute logger.



5
6
7
# File 'lib/jobi/configuration.rb', line 5

def logger
  @logger
end

#rabbitmq_configObject (readonly)

Returns the value of attribute rabbitmq_config.



5
6
7
# File 'lib/jobi/configuration.rb', line 5

def rabbitmq_config
  @rabbitmq_config
end

Instance Method Details

#rabbitmq(options = {}) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/jobi/configuration.rb', line 27

def rabbitmq(options = {})
  @rabbitmq_config ||= Jobi::Config::Rabbitmq.new
  @client = :rabbitmq

  options.keys.each do |key|
    @rabbitmq_config.send("#{key}=", options[key])
  end
end

#setup_loggerObject



36
37
38
39
40
41
42
43
44
# File 'lib/jobi/configuration.rb', line 36

def setup_logger
  @logger = if @log_file
              Logger.new(@log_file)
            else
              Logger.new(STDOUT)
            end

  @logger.level = @log_level
end