Module: Ampere

Defined in:
lib/ampere.rb,
lib/ampere/keys.rb,
lib/ampere/model.rb,
lib/rails/railtie.rb,
lib/ampere/collection.rb,
lib/ampere/timestamps.rb,
lib/rails/generators/ampere/model/model_generator.rb,
lib/rails/generators/ampere/config/config_generator.rb

Overview

:nodoc:

Defined Under Namespace

Modules: Generators, Keys, Model, Timestamps Classes: Collection, Railtie

Constant Summary collapse

@@connection =
nil

Class Method Summary collapse

Class Method Details

.connect(options = {}) ⇒ Object

Open a new Redis connection. ‘options` is passed directly to the Redis.connect method.



11
12
13
# File 'lib/ampere.rb', line 11

def self.connect(options = {})
  @@connection = Redis.connect(options)
end

.connected?Boolean

Returns ‘true` if the Redis connection is active.

Returns:

  • (Boolean)


23
24
25
# File 'lib/ampere.rb', line 23

def self.connected?
  !! @@connection
end

.connectionObject

Gives access to the Redis connection object.



28
29
30
# File 'lib/ampere.rb', line 28

def self.connection
  @@connection
end

.disconnectObject

Closes the Redis connection.



16
17
18
19
20
# File 'lib/ampere.rb', line 16

def self.disconnect
  return unless connected?
  @@connection.quit
  @@connection = nil
end

.flushObject

Alias for Ampere.redis.flushall



33
34
35
# File 'lib/ampere.rb', line 33

def self.flush
  @@connection.flushall if connected?
end