Sha256: ce0a352d2180325b3772d7893cb3ecf689589e00a26e0b365ac0434df875ccd5

Contents?: true

Size: 1.29 KB

Versions: 25

Compression:

Stored size: 1.29 KB

Contents

class ConnectionPool
  class Wrapper < ::BasicObject
    METHODS = [:with, :pool_shutdown, :wrapped_pool]

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

    def wrapped_pool
      @pool
    end

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

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

    def pool_size
      @pool.size
    end

    def pool_available
      @pool.available
    end

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

    # rubocop:disable Style/MissingRespondToMissing
    if ::RUBY_VERSION >= "3.0.0"
      def method_missing(name, *args, **kwargs, &block)
        with do |connection|
          connection.send(name, *args, **kwargs, &block)
        end
      end
    elsif ::RUBY_VERSION >= "2.7.0"
      ruby2_keywords def method_missing(name, *args, &block)
        with do |connection|
          connection.send(name, *args, &block)
        end
      end
    else
      def method_missing(name, *args, &block)
        with do |connection|
          connection.send(name, *args, &block)
        end
      end
    end
    # rubocop:enable Style/MethodMissingSuper
    # rubocop:enable Style/MissingRespondToMissing
  end
end

Version data entries

25 entries across 19 versions & 8 rubygems

Version Path
connection_pool-2.5.0 lib/connection_pool/wrapper.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/connection_pool-2.4.1/lib/connection_pool/wrapper.rb
direct7-0.0.18 vendor/bundle/ruby/3.0.0/gems/connection_pool-2.4.1/lib/connection_pool/wrapper.rb
direct7-0.0.18 vendor/bundle/ruby/2.7.0/gems/connection_pool-2.4.1/lib/connection_pool/wrapper.rb
direct7-0.0.17 vendor/bundle/ruby/3.0.0/gems/connection_pool-2.4.1/lib/connection_pool/wrapper.rb
direct7-0.0.17 vendor/bundle/ruby/2.7.0/gems/connection_pool-2.4.1/lib/connection_pool/wrapper.rb
direct7-0.0.16 vendor/bundle/ruby/3.0.0/gems/connection_pool-2.4.1/lib/connection_pool/wrapper.rb
direct7-0.0.16 vendor/bundle/ruby/2.7.0/gems/connection_pool-2.4.1/lib/connection_pool/wrapper.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/connection_pool-2.4.1/lib/connection_pool/wrapper.rb
katalyst-govuk-formbuilder-1.9.2 vendor/bundle/ruby/3.3.0/gems/connection_pool-2.4.1/lib/connection_pool/wrapper.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/connection_pool-2.4.1/lib/connection_pool/wrapper.rb
direct7-0.0.13 vendor/bundle/ruby/3.0.0/gems/connection_pool-2.4.1/lib/connection_pool/wrapper.rb
direct7-0.0.13 vendor/bundle/ruby/2.7.0/gems/connection_pool-2.4.1/lib/connection_pool/wrapper.rb
direct7-0.0.12 vendor/bundle/ruby/3.0.0/gems/connection_pool-2.4.1/lib/connection_pool/wrapper.rb
direct7-0.0.12 vendor/bundle/ruby/2.7.0/gems/connection_pool-2.4.1/lib/connection_pool/wrapper.rb
mlh-rubocop-config-1.0.3 vendor/bundle/ruby/3.2.0/gems/connection_pool-2.4.1/lib/connection_pool/wrapper.rb
direct7-0.0.11 vendor/bundle/ruby/3.0.0/gems/connection_pool-2.4.1/lib/connection_pool/wrapper.rb
direct7-0.0.11 vendor/bundle/ruby/2.7.0/gems/connection_pool-2.4.1/lib/connection_pool/wrapper.rb
rubypitaya-3.12.5 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/connection_pool-2.3.0/lib/connection_pool/wrapper.rb
connection_pool-2.4.1 lib/connection_pool/wrapper.rb