Class: Net::WebMockNetBufferedIO
- Inherits:
-
BufferedIO
- Object
- BufferedIO
- Net::WebMockNetBufferedIO
- Defined in:
- lib/webmock/http_lib_adapters/net_http.rb
Instance Method Summary collapse
-
#initialize(io, *args, **kwargs) ⇒ WebMockNetBufferedIO
constructor
A new instance of WebMockNetBufferedIO.
- #rbuf_fill ⇒ Object
Constructor Details
#initialize(io, *args, **kwargs) ⇒ WebMockNetBufferedIO
Returns a new instance of WebMockNetBufferedIO.
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/webmock/http_lib_adapters/net_http.rb', line 260 def initialize(io, *args, **kwargs) io = case io when Socket, OpenSSL::SSL::SSLSocket, IO io when StringIO PatchedStringIO.new(io.string) when String PatchedStringIO.new(io) end raise "Unable to create local socket" unless io # Prior to 2.4.0 `BufferedIO` only takes a single argument (`io`) with no # options. Here we pass through our full set of arguments only if we're # on 2.4.0 or later, and use a simplified invocation otherwise. if RUBY_VERSION >= '2.4.0' super else super(io) end end |
Instance Method Details
#rbuf_fill ⇒ Object
282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'lib/webmock/http_lib_adapters/net_http.rb', line 282 def rbuf_fill current_thread_id = Thread.current.object_id trace = TracePoint.trace(:line) do |tp| next unless Thread.current.object_id == current_thread_id if tp.binding.local_variable_defined?(:tmp) tp.binding.local_variable_set(:tmp, nil) end end super ensure trace.disable end |