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"
@@topic_prefix =
"banter"
@@logging_enabled =
true
@@push_enabled =
true
@@batch_messages =
false
@@web_enabled =
false
@@application_name =
nil

Class Method Summary collapse

Class Method Details

.configurationObject



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

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

.configure_with(environment_name, yaml_file = nil) ⇒ Object



50
51
52
53
54
55
# File 'lib/banter/configuration.rb', line 50

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

.connectionObject



62
63
64
# File 'lib/banter/configuration.rb', line 62

def self.connection
  configuration[:connection]
end

.environmentObject



66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/banter/configuration.rb', line 66

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