Class: EzPool::Wrapper

Inherits:
BasicObject
Defined in:
lib/ezpool.rb

Constant Summary collapse

METHODS =
[:with, :pool_shutdown]

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, &block) ⇒ Wrapper

Returns a new instance of Wrapper.



168
169
170
# File 'lib/ezpool.rb', line 168

def initialize(options = {}, &block)
  @pool = options.fetch(:pool) { ::EzPool.new(options, &block) }
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



184
185
186
187
188
# File 'lib/ezpool.rb', line 184

def method_missing(name, *args, &block)
  with do |connection|
    connection.send(name, *args, &block)
  end
end

Instance Method Details

#pool_shutdown(&block) ⇒ Object



176
177
178
# File 'lib/ezpool.rb', line 176

def pool_shutdown(&block)
  @pool.shutdown(&block)
end

#respond_to?(id, *args) ⇒ Boolean

Returns:

  • (Boolean)


180
181
182
# File 'lib/ezpool.rb', line 180

def respond_to?(id, *args)
  METHODS.include?(id) || with { |c| c.respond_to?(id, *args) }
end

#with(&block) ⇒ Object



172
173
174
# File 'lib/ezpool.rb', line 172

def with(&block)
  @pool.with(&block)
end