net-http
net-http copied to clipboard
Refining classes in net/http
What is the proper way to refine the initializer of this class? The below does not seem work.
require 'net/http'
module Foo
refine Gem::Net::HTTPGenericRequest.singleton_class do
def new(*)
obj = super
puts 'IT WORKS!
obj
end
end
end
using Foo
http = Net::HTTP.new('localhost', '8080')
http.send_request('GET', '/')
@HoneyryderChuck: Do you have a solution here?
Gem:Net::HTTPGenericRequest is different with Net::HTTPGenericRequest class.
https://github.com/rubygems/rubygems/blob/master/lib/rubygems/vendor/net-http/lib/net/http/generic_request.rb#L11
You shouldn't mix them.