Module: Pools::Pooled::ClassMethods

Defined in:
lib/pools/pooled.rb

Instance Method Summary collapse

Instance Method Details

#connection_methods(*methods) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/pools/pooled.rb', line 33

def connection_methods(*methods)
  methods.each do |method|
    define_method(method) do |*args, **kwargs, &block|
      with_connection do |client|
        # https://bugs.ruby-lang.org/issues/14415
        # Needed for pre-2.5 Ruby support
        if !kwargs.empty?
          client.send(method, *args, **kwargs, &block)
        else
          client.send(method, *args, &block)
        end
      end
    end
  end
end

#preparation_methods(*methods) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/pools/pooled.rb', line 49

def preparation_methods(*methods)
  methods.each do |method|
    define_method(method) do |*params|
      @preparation_chain << ([method] + params)
    end
  end
end