Class: EbisuConnection::ConfFile

Inherits:
Object
  • Object
show all
Defined in:
lib/ebisu_connection/conf_file.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.check_intervalObject



36
37
38
# File 'lib/ebisu_connection/conf_file.rb', line 36

def check_interval
  @check_interval || 1.minute
end

.slaves_fileObject



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

def slaves_file
  return @slaves_file if @slaves_file
  raise "nothing slaves_file. You have to set a file path using EbisuConnection.slaves_file= method" unless defined?(Rails)

  @slaves_file = %w(yml yaml).map{|ext| Rails.root.join("config/slave.#{ext}").to_s }.detect {|f| File.exist?(f) }
  raise "nothing slaves_file. You have to put a config/slave.yml file" unless @slaves_file
  @slaves_file
end

Class Method Details

.conf_clear!Object



14
15
16
# File 'lib/ebisu_connection/conf_file.rb', line 14

def conf_clear!
  @slaves_conf = nil
end

.if_modifyObject



8
9
10
11
12
# File 'lib/ebisu_connection/conf_file.rb', line 8

def if_modify
  if time_to_check? && modify?
    yield
  end
end

.slaves_conf(slave_group) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/ebisu_connection/conf_file.rb', line 18

def slaves_conf(slave_group)
  @slaves_conf ||= get_slaves_conf
  if @slaves_conf.is_a?(Hash)
    @slaves_conf[slave_group] || @slaves_conf
  else
    @slaves_conf
  end
end