Class: RedisConnection
- Inherits:
-
Object
- Object
- RedisConnection
- Defined in:
- lib/redis_connection.rb
Constant Summary collapse
- @@redis_connections =
{}
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ RedisConnection
constructor
A new instance of RedisConnection.
- #method_missing(m, *args, &block) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ RedisConnection
Returns a new instance of RedisConnection.
5 6 7 8 9 10 11 12 |
# File 'lib/redis_connection.rb', line 5 def initialize(={}) key = .keys.sort.map{|k| "#{k}:#{[k]}"}.join(",") unless @@redis_connections.has_key?(key) @@redis_connections[key] = Redis.new() end @current_connection = @@redis_connections[key] @current_connection end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/redis_connection.rb', line 14 def method_missing(m, *args, &block) if @current_connection.respond_to?(m) @current_connection.send(m, *args) else super end end |