Skip to content

Commit b9e0c13

Browse files
thekuwayamaioquatix
authored andcommitted
add SSLSocket.open as alias of SSLSocket.new
1 parent feb6d2c commit b9e0c13

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

lib/openssl/ssl.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,12 @@ def session_new_cb
440440
def session_get_cb
441441
@context.session_get_cb
442442
end
443+
444+
class << self
445+
##
446+
# open is an alias to ::new
447+
alias open new
448+
end
443449
end
444450

445451
##

test/test_ssl.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,6 +1592,17 @@ def test_fileno
15921592
sock2.close
15931593
end
15941594

1595+
def test_ssl_socket_new_alias
1596+
mn = OpenSSL::SSL::SSLSocket.method(:new)
1597+
mo = OpenSSL::SSL::SSLSocket.method(:open)
1598+
1599+
if mn.inspect == "#<Method: Class#new>"
1600+
assert_equal mn.hash, mo.hash
1601+
else
1602+
assert_equal mn, mo
1603+
end
1604+
end
1605+
15951606
private
15961607

15971608
def start_server_version(version, ctx_proc = nil,

0 commit comments

Comments
 (0)