fixing chainable mod sigs

This commit is contained in:
HoneyryderChuck 2021-07-06 22:45:07 +01:00
parent d59137e90d
commit c9acb1d079

View File

@ -43,12 +43,12 @@ module HTTPX
# deprecated # deprecated
# :nocov: # :nocov:
def plugins(*args, **opts) def plugins(pls)
warn ":#{__method__} is deprecated, use :plugin instead" warn ":#{__method__} is deprecated, use :plugin instead"
klass = is_a?(Session) ? self.class : Session klass = is_a?(Session) ? self.class : Session
klass = Class.new(klass) klass = Class.new(klass)
klass.instance_variable_set(:@default_options, klass.default_options.merge(default_options)) klass.instance_variable_set(:@default_options, klass.default_options.merge(default_options))
klass.plugins(*args, **opts).new klass.plugins(pls).new
end end
# :nocov: # :nocov:
@ -71,12 +71,15 @@ module HTTPX
def method_missing(meth, *args, **options) def method_missing(meth, *args, **options)
return super unless meth =~ /\Awith_(.+)/ return super unless meth =~ /\Awith_(.+)/
option = Regexp.last_match(1).to_sym option = Regexp.last_match(1)
with(option => (args.first || options))
return super unless option
with(option.to_sym => (args.first || options))
end end
def respond_to_missing?(meth, *args) def respond_to_missing?(meth)
default_options.respond_to?(meth, *args) || super default_options.respond_to?(meth) || super
end end
end end
end end