[前][次][番号順一覧][スレッド一覧]

ruby-changes:32036

From: nobu <ko1@a...>
Date: Tue, 10 Dec 2013 16:16:09 +0900 (JST)
Subject: [ruby-changes:32036] nobu:r44116 (trunk): openssl/digest.rb: check by lambda

nobu	2013-12-10 16:16:03 +0900 (Tue, 10 Dec 2013)

  New Revision: 44116

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44116

  Log:
    openssl/digest.rb: check by lambda
    
    * ext/openssl/lib/openssl/digest.rb (initialize): check argument
      size by lambda.

  Modified files:
    trunk/ext/openssl/lib/openssl/digest.rb
Index: ext/openssl/lib/openssl/digest.rb
===================================================================
--- ext/openssl/lib/openssl/digest.rb	(revision 44115)
+++ ext/openssl/lib/openssl/digest.rb	(revision 44116)
@@ -42,14 +42,8 @@ module OpenSSL https://github.com/ruby/ruby/blob/trunk/ext/openssl/lib/openssl/digest.rb#L42
     end
 
     alg.each{|name|
-      klass = Class.new(Digest){
-        define_method(:initialize){|*data|
-          if data.length > 1
-            raise ArgumentError,
-              "wrong number of arguments (#{data.length} for 1)"
-          end
-          super(name, data.first)
-        }
+      klass = Class.new(self) {
+        define_method(:initialize, ->(data = nil) {super(name, data)})
       }
       singleton = (class << klass; self; end)
       singleton.class_eval{

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]