Module: Banter::Configuration

Defined in:
lib/banter/configuration.rb

Constant Summary collapse

@@conf =
nil
@@default_queue_ttl =

10 hours in seconds

36000
@@exchange_name =
"banter"
@@dead_letter_exchange_name =
"banter-dlx"
@@dead_letter_queue_name =
"deadletter"
@@topic_prefix =
"banter"
@@durable_queues =
true
@@logging_enabled =
true
@@push_enabled =
true
@@batch_messages =
false
@@application_name =
nil
@@pool_size =
100

Class Method Summary collapse

Class Method Details

.configurationObject



65
66
67
68
# File 'lib/banter/configuration.rb', line 65

def self.configuration
  self.configure_with(self.environment) if @@conf.nil?
  @@conf
end

.configure_with(environment_name, yaml_file = nil) ⇒ Object



57
58
59
60
61
62
63
# File 'lib/banter/configuration.rb', line 57

def self.configure_with(environment_name, yaml_file = nil)
  @@yaml_file = yaml_file.nil? ? "config/banter.yml" : yaml_file
  yaml_data = YAML.load(ERB.new(File.read(@@yaml_file)).result)
  @@all_conf = Hashie::Mash.new(yaml_data)
  @@conf = @@all_conf[environment_name]
  self
end

.connectionObject



70
71
72
# File 'lib/banter/configuration.rb', line 70

def self.connection
  configuration[:connection]
end

.environmentObject



74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/banter/configuration.rb', line 74

def self.environment
  val = ENV["RAILS_ENV"] || ENV["RACK_ENV"]
  val = if val.present?
    val.to_sym
  else
    if defined?(Rails)
      Rails.env
    else
      raise "No environment can be found for configuration!"
    end
  end
end