Class: Redis::Objects::ConnectionPoolProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/redis/objects/connection_pool_proxy.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pool) ⇒ ConnectionPoolProxy

Returns a new instance of ConnectionPoolProxy.



4
5
6
7
# File 'lib/redis/objects/connection_pool_proxy.rb', line 4

def initialize(pool)
  raise ArgumentError "Should only proxy ConnectionPool!" unless self.class.should_proxy?(pool)
  @pool = pool
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



9
10
11
# File 'lib/redis/objects/connection_pool_proxy.rb', line 9

def method_missing(name, *args, &block)
  @pool.with { |x| x.send(name, *args, &block) }
end

Class Method Details

.proxy_if_needed(conn) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/redis/objects/connection_pool_proxy.rb', line 21

def self.proxy_if_needed(conn)
  if should_proxy?(conn)
    ConnectionPoolProxy.new(conn)
  else
    conn
  end
end

.should_proxy?(conn) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/redis/objects/connection_pool_proxy.rb', line 17

def self.should_proxy?(conn)
  defined?(::ConnectionPool) && conn.is_a?(::ConnectionPool)
end

Instance Method Details

#respond_to_missing?(name, include_all = false) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/redis/objects/connection_pool_proxy.rb', line 13

def respond_to_missing?(name, include_all = false)
  @pool.with { |x| x.respond_to?(name, include_all) }
end