-
-
Notifications
You must be signed in to change notification settings - Fork 419
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
34 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
module Flipper | ||
module Adapters | ||
module Poolable | ||
def initialize(client_or_pool = nil, key_prefix: nil) | ||
@pool = nil | ||
@client = nil | ||
if client_or_pool.respond_to?(:with) | ||
@pool = client_or_pool | ||
else | ||
@client = client_or_pool | ||
end | ||
@key_prefix = key_prefix | ||
end | ||
|
||
def self.included(klass) | ||
klass.superclass.instance_methods(false).each do |method| | ||
klass.define_method method do |*args| | ||
return super(*args) unless @client.nil? | ||
|
||
@pool.with do |client| | ||
@client = client | ||
super(*args).tap { @client = nil } | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.