From: "nobu (Nobuyoshi Nakada)" Date: 2012-08-01T17:11:56+09:00 Subject: [ruby-core:46910] [ruby-trunk - Feature #6819] OpenSSL::Digest.new should return an instance of the chosen subclass Issue #6819 has been updated by nobu (Nobuyoshi Nakada). drbrain (Eric Hodel) wrote: > I would like this changed so that it returns the specific subclass of OpenSSL::Digest: > > digester = OpenSSL::Digest.new "SHA1" > digester.class #=> OpenSSL::Digest::SHA1 It sounds like quite exceptional. Rather I'd suggest OpenSSL.Digest() method as well as Digest(), or new similar class method. > This will also make OpenSSL::Digest.new behave similarly to Digest: > > digester = Digest("SHA1").new > digester.class #=> Digest::SHA1 It differs than your proposal. ---------------------------------------- Feature #6819: OpenSSL::Digest.new should return an instance of the chosen subclass https://bugs.ruby-lang.org/issues/6819#change-28577 Author: drbrain (Eric Hodel) Status: Open Priority: Normal Assignee: MartinBosslet (Martin Bosslet) Category: ext Target version: 2.0.0 =begin OpenSSL::Digest.new allows you to create a digest given the digest name: digester = OpenSSL::Digest.new "SHA1" digester.update "hello" # ��� The digester returned is of class OpenSSL::Digest regardless of the input type. I would like this changed so that it returns the specific subclass of OpenSSL::Digest: digester = OpenSSL::Digest.new "SHA1" digester.class #=> OpenSSL::Digest::SHA1 When multiple digests are created this makes it easier to distinguish the type of digest you are working with. This will also make OpenSSL::Digest.new behave similarly to Digest: digester = Digest("SHA1").new digester.class #=> Digest::SHA1 =end -- http://bugs.ruby-lang.org/