lib/httpx/chainable.rb in httpx-0.23.4 vs lib/httpx/chainable.rb in httpx-0.24.0
- old
+ new
@@ -8,10 +8,23 @@
request("#{meth.upcase}", uri, **options) # request("GET", uri, **options)
end # end
MOD
end
+ %i[
+ connection_opened connection_closed
+ request_error
+ request_started request_body_chunk request_completed
+ response_started response_body_chunk response_completed
+ ].each do |meth|
+ class_eval(<<-MOD, __FILE__, __LINE__ + 1)
+ def on_#{meth}(&blk) # def on_connection_opened(&blk)
+ on(:#{meth}, &blk) # on(:connection_opened, &blk)
+ end # end
+ MOD
+ end
+
def request(*args, **options)
branch(default_options).request(*args, **options)
end
# :nocov:
@@ -52,9 +65,15 @@
end
# :nocov:
def with(options, &blk)
branch(default_options.merge(options), &blk)
+ end
+
+ protected
+
+ def on(*args, &blk)
+ branch(default_options).on(*args, &blk)
end
private
def default_options