Module: TcpUserTimeout::Hook::TCPSocketSingleton

Defined in:
lib/tcp_user_timeout/hook.rb

Instance Method Summary collapse

Instance Method Details

#new(*args, **kwargs) ⇒ Object

TCPSocket.new is the underlying constructor — covers paths that bypass ‘open`. Explicit hook because `open` is sometimes an alias for `new` and sometimes its own method depending on Ruby version.



37
38
39
40
41
# File 'lib/tcp_user_timeout/hook.rb', line 37

def new(*args, **kwargs)
  sock = super
  TcpUserTimeout.maybe_apply!(sock)
  sock
end

#open(*args, **kwargs) ⇒ Object



28
29
30
31
32
# File 'lib/tcp_user_timeout/hook.rb', line 28

def open(*args, **kwargs)
  sock = super
  TcpUserTimeout.maybe_apply!(sock)
  sock
end