Class: DevSuite::RequestLogger::Adapter::Faraday
- Inherits:
-
Base
- Object
- Utils::Construct::Component::Base
- Base
- DevSuite::RequestLogger::Adapter::Faraday
- Defined in:
- lib/dev_suite/request_logger/adapter/faraday.rb
Instance Method Summary collapse
Methods inherited from Utils::Construct::Component::Base
Instance Method Details
#disable ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/dev_suite/request_logger/adapter/faraday.rb', line 30 def disable return unless faraday_defined? ::Faraday::Connection.class_eval do alias_method(:run_request, :_original_run_request) remove_method(:_original_run_request) end end |
#enable ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/dev_suite/request_logger/adapter/faraday.rb', line 9 def enable return unless faraday_defined? ::Faraday::Connection.class_eval do alias_method(:_original_run_request, :run_request) def run_request(method, url, body, headers, &block) env = ::Faraday::Env.new(method, url, body, headers) env.request = @request env.params = @params env.request_body = @request_body env.ssl = @ssl env.response = @response Middleware::Faraday.new(lambda do |e| _original_run_request(e.method, e.url, e.body, e.request_headers, &block) end).call(env, self) end end end |