Module: Pools::Pooled

Extended by:
ActiveSupport::Concern
Included in:
Cassandra::Pooled, CassandraCQL::Pooled, Redis::Pooled
Defined in:
lib/pools/pooled.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#connection_poolObject (readonly)

Returns the value of attribute connection_pool.



7
8
9
# File 'lib/pools/pooled.rb', line 7

def connection_pool
  @connection_pool
end

#preparation_chainObject (readonly)

Returns the value of attribute preparation_chain.



7
8
9
# File 'lib/pools/pooled.rb', line 7

def preparation_chain
  @preparation_chain
end

Instance Method Details

#__connectionObject



22
23
24
# File 'lib/pools/pooled.rb', line 22

def __connection
  # Override in parent
end

#__disconnect(connection) ⇒ Object



26
27
28
# File 'lib/pools/pooled.rb', line 26

def __disconnect(connection)
  # Override in parent
end

#__prepare(connection) ⇒ Object



30
31
32
# File 'lib/pools/pooled.rb', line 30

def __prepare(connection)
  @preparation_chain.each { |args| connection.send(*args) }
end

#initialize(*args) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/pools/pooled.rb', line 9

def initialize(*args)
  options = args.extract_options!
  pool_name = options.delete(:pool_name)

  @preparation_chain = []
  @connection_pool = ConnectionPool.new(self, options)
  Pools.handler.add(@connection_pool, pool_name)
end

#with_connection(&block) ⇒ Object



18
19
20
# File 'lib/pools/pooled.rb', line 18

def with_connection(&block)
  @connection_pool.with_connection(&block)
end