Sha256: 0a8e803fb1b21c857a046828c8cc27447600f764172239dcb6424168eb21161f
Contents?: true
Size: 767 Bytes
Versions: 4
Compression:
Stored size: 767 Bytes
Contents
module SimpleRedisOrm class ConnectionPoolProxy def initialize(pool) raise ArgumentError "Should only proxy ConnectionPool!" unless self.class.should_proxy?(pool) @pool = pool end def method_missing(name, *args, &block) @pool.with { |x| x.send(name, *args, &block) } end ruby2_keywords :method_missing if respond_to?(:ruby2_keywords, true) def respond_to_missing?(name, include_all = false) @pool.with { |x| x.respond_to?(name, include_all) } end def self.should_proxy?(conn) defined?(::ConnectionPool) && conn.is_a?(::ConnectionPool) end def self.proxy_if_needed(conn) if should_proxy?(conn) ConnectionPoolProxy.new(conn) else conn end end end end
Version data entries
4 entries across 4 versions & 1 rubygems