allow for merging of default options from extended classes (important for passing along altered http classes)

This commit is contained in:
HoneyryderChuck 2018-02-08 23:56:38 +00:00
parent 930e654b51
commit de35b9efad

View File

@ -25,7 +25,10 @@ module HTTPX
end
def plugin(*plugins)
Class.new(Client).plugins(plugins).new
klass = self.is_a?(Client) ? self.class : Client
klass = Class.new(klass)
klass.instance_variable_set(:@default_options, klass.default_options.merge(default_options))
klass.plugins(plugins).new
end
alias_method :plugins, :plugin