lib/httpx/chainable.rb in httpx-0.15.4 vs lib/httpx/chainable.rb in httpx-0.16.0
- old
+ new
@@ -32,25 +32,25 @@
def wrap(&blk)
branch(default_options).wrap(&blk)
end
- def plugin(*args, **opts, &blk)
+ def plugin(pl, options = nil, &blk)
klass = is_a?(Session) ? self.class : Session
klass = Class.new(klass)
klass.instance_variable_set(:@default_options, klass.default_options.merge(default_options))
- klass.plugin(*args, **opts, &blk).new
+ klass.plugin(pl, options, &blk).new
end
# deprecated
# :nocov:
- def plugins(*args, **opts)
+ def plugins(pls)
warn ":#{__method__} is deprecated, use :plugin instead"
klass = is_a?(Session) ? self.class : Session
klass = Class.new(klass)
klass.instance_variable_set(:@default_options, klass.default_options.merge(default_options))
- klass.plugins(*args, **opts).new
+ klass.plugins(pls).new
end
# :nocov:
def with(options, &blk)
branch(default_options.merge(options), &blk)
@@ -69,14 +69,21 @@
end
def method_missing(meth, *args, **options)
return super unless meth =~ /\Awith_(.+)/
- option = Regexp.last_match(1).to_sym
- with(option => (args.first || options))
+ option = Regexp.last_match(1)
+
+ return super unless option
+
+ with(option.to_sym => (args.first || options))
end
- def respond_to_missing?(meth, *args)
- default_options.respond_to?(meth, *args) || super
+ def respond_to_missing?(meth)
+ return super unless meth =~ /\Awith_(.+)/
+
+ option = Regexp.last_match(1)
+
+ default_options.respond_to?(option) || super
end
end
end