Module: PulseToolbox

Extended by:
ActiveSupport::Autoload
Defined in:
lib/pulse-meter-rails.rb,
lib/pulse_toolbox/version.rb,
lib/pulse_toolbox/sensor/manager.rb,
lib/pulse_toolbox/sensor/initializer.rb,
lib/pulse_toolbox/sensor/mixins/iterators.rb,
lib/generators/pulse_toolbox/install_generator.rb

Defined Under Namespace

Modules: Generators, Sensor, Server Classes: InstallGenerator

Constant Summary collapse

VERSION =
"0.1.4"
@@pid =
nil
@@redis_config =
{}

Class Method Summary collapse

Class Method Details

.maybe_reconnectObject



58
59
60
# File 'lib/pulse-meter-rails.rb', line 58

def maybe_reconnect
  reconnect if pid_changed
end

.pid_changedObject



62
63
64
# File 'lib/pulse-meter-rails.rb', line 62

def pid_changed
  @@pid && @@pid != Process.pid
end

.reconnectObject



50
51
52
53
54
55
56
# File 'lib/pulse-meter-rails.rb', line 50

def reconnect
  PulseMeter.redis = Redis.new(
    host: @@redis_config[:host],
    port: @@redis_config[:port],
    db: @@redis_config[:db]
  )
end

.redisObject



45
46
47
48
# File 'lib/pulse-meter-rails.rb', line 45

def redis
  reconnect if pid_changed
  PulseMeter.redis
end

.redis=(redis) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/pulse-meter-rails.rb', line 35

def redis=(redis)
  PulseMeter.redis = redis
  @@pid = Process.pid
  @@redis_config = {
    host: redis.client.host,
    port: redis.client.port,
    db: redis.client.db
  }
end