lib/httpx/chainable.rb in httpx-0.6.7 vs lib/httpx/chainable.rb in httpx-0.7.0
- old
+ new
@@ -10,20 +10,24 @@
def request(verb, uri, **options)
branch(default_options).request(verb, uri, **options)
end
+ # :nocov:
def timeout(**args)
- branch(default_options.with_timeout(args))
+ warn ":#{__method__} is deprecated, use :with_timeout instead"
+ branch(default_options.with(timeout: args))
end
def headers(headers)
- branch(default_options.with_headers(headers))
+ warn ":#{__method__} is deprecated, use :with_headers instead"
+ branch(default_options.with(headers: headers))
end
+ # :nocov:
def accept(type)
- headers("accept" => String(type))
+ with(headers: { "accept" => String(type) })
end
def wrap(&blk)
branch(default_options).wrap(&blk)
end
@@ -56,8 +60,21 @@
# :nodoc:
def branch(options, &blk)
return self.class.new(options, &blk) if is_a?(Session)
Session.new(options, &blk)
+ end
+
+ def method_missing(meth, *args, **options)
+ if meth =~ /\Awith_(.+)/
+ option = Regexp.last_match(1).to_sym
+ with(option => (args.first || options))
+ else
+ super
+ end
+ end
+
+ def respond_to_missing?(meth, *args)
+ default_options.respond_to?(meth, *args) || super
end
end
end