Skip to content

Commit 8657ec1

Browse files
committed
Further simplify delegation
1 parent afd41ab commit 8657ec1

File tree

1 file changed

+6
-14
lines changed
  • lib/openssl/signature_algorithm

1 file changed

+6
-14
lines changed

lib/openssl/signature_algorithm/rsa.rb

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,23 @@
77
module OpenSSL
88
module SignatureAlgorithm
99
class RSA < Base
10-
class SigningKey < Delegator
11-
def __getobj__
12-
@pkey
13-
end
14-
10+
class SigningKey < DelegateClass(OpenSSL::PKey::RSA)
1511
def initialize(*args)
16-
@pkey = OpenSSL::PKey::RSA.new(*args)
12+
super(OpenSSL::PKey::RSA.new(*args))
1713
end
1814

1915
def verify_key
2016
VerifyKey.new(public_key.to_pem)
2117
end
2218
end
2319

24-
class VerifyKey < Delegator
25-
def __getobj__
26-
@pkey
20+
class VerifyKey < DelegateClass(OpenSSL::PKey::RSA)
21+
class << self
22+
alias_method :deserialize, :new
2723
end
2824

2925
def initialize(*args)
30-
@pkey = OpenSSL::PKey::RSA.new(*args)
31-
end
32-
33-
class << self
34-
alias_method :deserialize, :new
26+
super(OpenSSL::PKey::RSA.new(*args))
3527
end
3628

3729
def serialize

0 commit comments

Comments
 (0)