Class: AbstractFeatureBranch::Redis::ConnectionPoolToRedisAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/abstract_feature_branch/redis/connection_pool_to_redis_adapter.rb

Overview

Adapts a ConnectionPool instance to the Redis object interface

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection_pool) ⇒ ConnectionPoolToRedisAdapter

Returns a new instance of ConnectionPoolToRedisAdapter.



7
8
9
# File 'lib/abstract_feature_branch/redis/connection_pool_to_redis_adapter.rb', line 7

def initialize(connection_pool)
  @connection_pool = connection_pool
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/abstract_feature_branch/redis/connection_pool_to_redis_adapter.rb', line 19

def method_missing(method_name, *args, &block)
  connection_can_respond_to = nil
  result = nil
  @connection_pool.with do |connection|
    connection_can_respond_to = connection.respond_to?(method_name, true)
    result = connection.send(method_name, *args, &block) if connection_can_respond_to
  end
  if connection_can_respond_to
    result
  else
    super
  end
end

Instance Attribute Details

#connection_poolObject (readonly)

Returns the value of attribute connection_pool.



5
6
7
# File 'lib/abstract_feature_branch/redis/connection_pool_to_redis_adapter.rb', line 5

def connection_pool
  @connection_pool
end

Instance Method Details

#respond_to?(method_name, include_private = false, &block) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
17
# File 'lib/abstract_feature_branch/redis/connection_pool_to_redis_adapter.rb', line 11

def respond_to?(method_name, include_private = false, &block)
  result = false
  @connection_pool.with do |connection|
    result ||= connection.respond_to?(method_name, include_private, &block)
  end
  result || super
end