Skip to content

Commit 20833bb

Browse files
committed
Add ability to change stack.
1 parent 66bdf10 commit 20833bb

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

lib/github_api/connection.rb

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,11 @@ def caching?
4040
# Exposes middleware builder to facilitate custom stacks and easy
4141
# addition of new extensions such as cache adapter.
4242
#
43-
def stack(options = {}, &block)
43+
# @api public
44+
def stack(options = {})
4445
@stack ||= begin
4546
builder_class = defined?(Faraday::RackBuilder) ? Faraday::RackBuilder : Faraday::Builder
46-
47-
if block_given?
48-
builder_class.new(&block)
49-
else
50-
builder_class.new(&Github.default_middleware(options))
51-
end
47+
builder_class.new(&Github.default_middleware(options))
5248
end
5349
end
5450

@@ -58,7 +54,8 @@ def stack(options = {}, &block)
5854
def connection(api, options = {})
5955
connection_options = default_options(options)
6056
clear_cache unless options.empty?
61-
connection_options.merge!(builder: stack(options.merge!(api: api)))
57+
builder = api.stack ? api.stack : stack(options.merge!(api: api))
58+
connection_options.merge!(builder: builder)
6259
if ENV['DEBUG']
6360
p "Connection options : \n"
6461
pp connection_options

0 commit comments

Comments
 (0)