I'm developing some tool using pure ruby and RestClient and I'd like to override default log_request method of Request class.
lib/restclient/request.rb
module RestClient
class Request
def log_request
RestClient.log << "SECRET"
end
end
end
But now, if I try to test this, it is not working:
$ irb
irb(main):001:0> require 'restclient'
=> true
irb(main):002:0> RestClient.log = "stdout"
=> "stdout"
irb(main):003:0> RestClient.get("http://localhost")
RestClient.get "http://localhost", "Accept"=>"*/*; q=0.5, application/xml", "Accept-Encoding"=>"gzip, deflate"
Expected to see only SECRET
as output.
I'm probably missing, how to "inject" my code in default RestClient library ?
How can I do this from another file in lib/mytool/somefile.rb ?
This file need to be exactly required after require 'restclient'
Adding load 'lib/restclient/request.rb'
did the trick