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

ruby-changes:38227

From: nobu <ko1@a...>
Date: Tue, 14 Apr 2015 12:35:31 +0900 (JST)
Subject: [ruby-changes:38227] nobu:r50308 (trunk): ostruct.rb: match Symbol itself

nobu	2015-04-14 12:35:18 +0900 (Tue, 14 Apr 2015)

  New Revision: 50308

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

  Log:
    ostruct.rb: match Symbol itself
    
    * lib/ostruct.rb (method_missing): get rid of creating temporary
      string object for method name, match Symbol itself.

  Modified files:
    trunk/lib/ostruct.rb
Index: lib/ostruct.rb
===================================================================
--- lib/ostruct.rb	(revision 50307)
+++ lib/ostruct.rb	(revision 50308)
@@ -174,9 +174,8 @@ class OpenStruct https://github.com/ruby/ruby/blob/trunk/lib/ostruct.rb#L174
   protected :new_ostruct_member
 
   def method_missing(mid, *args) # :nodoc:
-    mname = mid.id2name
     len = args.length
-    if mname.chomp!('=')
+    if mname = mid[/.*(?==\z)/m]
       if len != 1
         raise ArgumentError, "wrong number of arguments (#{len} for 1)", caller(1)
       end

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

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