From ruby-talk-admin@ruby-lang.org Fri Dec 16 00:14:39 2005 Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (8.12.3/8.12.3/Debian-6.6) with ESMTP id jBFFEdZk022342; Fri, 16 Dec 2005 00:14:39 +0900 Received: from funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [133.44.2.201]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id 8F4665D14; Fri, 16 Dec 2005 00:14:40 +0900 (JST) Received: from localhost (localhost.nagaokaut.ac.jp [127.0.0.1]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id 51AF0F0489B; Fri, 16 Dec 2005 00:14:44 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id 0140AF04899; Fri, 16 Dec 2005 00:14:43 +0900 (JST) Received: from beryllium.ruby-lang.org (beryllium.ruby-lang.org [210.163.138.100]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id A58C3630024; Fri, 16 Dec 2005 00:14:45 +0900 (JST) Received: from beryllium.ruby-lang.org (beryllium.ruby-lang.org [127.0.0.1]) by beryllium.ruby-lang.org (Postfix) with ESMTP id BF78033D3A; Fri, 16 Dec 2005 00:14:32 +0900 (JST) Received: from localhost (beryllium.ruby-lang.org [127.0.0.1]) by beryllium.ruby-lang.org (Postfix) with ESMTP id B3A1733ECD for ; Fri, 16 Dec 2005 00:14:22 +0900 (JST) Received: from beryllium.ruby-lang.org ([127.0.0.1]) by localhost (beryllium.ruby-lang.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 09781-04 for ; Fri, 16 Dec 2005 00:14:22 +0900 (JST) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.193]) by beryllium.ruby-lang.org (Postfix) with ESMTP id F0B1E33C88 for ; Fri, 16 Dec 2005 00:14:21 +0900 (JST) Received: by zproxy.gmail.com with SMTP id x3so416257nzd for ; Thu, 15 Dec 2005 07:14:16 -0800 (PST) Received: by 10.65.186.7 with SMTP id n7mr1059356qbp; Thu, 15 Dec 2005 07:14:16 -0800 (PST) Received: by 10.64.131.7 with HTTP; Thu, 15 Dec 2005 07:14:16 -0800 (PST) Delivered-To: ruby-talk@ruby-lang.org Date: Fri, 16 Dec 2005 00:14:23 +0900 Posted: Thu, 15 Dec 2005 10:14:16 -0500 From: John Lam Reply-To: ruby-talk@ruby-lang.org Subject: Re: Dynamically adding methods to a Ruby class To: ruby-talk@ruby-lang.org (ruby-talk ML) Message-Id: In-Reply-To: <1d7ddd110512142352x3fe1506o3cefd7f1999991c2@mail.gmail.com> References: <1d7ddd110512142352x3fe1506o3cefd7f1999991c2@mail.gmail.com> X-ML-Name: ruby-talk X-Mail-Count: 45 X-MLServer: fml [fml 4.0.3 release (20011202/4.0.3)]; post only (only members can post) X-ML-Info: If you have a question, send e-mail with the body "help" (without quotes) to the address ruby-talk-ctl@ruby-lang.org; help= X-Original-To: ruby-talk@ruby-lang.org DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=gYl5Gmz5iyOHx3UO6BpAuMQOTLnl5sxc6ZhDfvuV44a+Dl3wVwzGU0D/z7phEel1ilXjaJeQAMMfsATRzpwyWEti29bRS7ayqSJhHCFQEwSao1bZmJlc/QKtZtbd9arvt08dEl+LG3n7m7xGj32mB7K+Zhobn/aBD9xBvg/C94M= X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at ruby-lang.org X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on beryllium.ruby-lang.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=7.0 tests=AWL,BAYES_00,BLARS00, BLARS_SPAM00,CONTENT_TYPE_PRESENT,HTML_10_20,HTML_MESSAGE,MIMEQENC, MULTIPART_ALTERNATIVE,QENCPTR1,QENCPTR2,RCVDFRMLOCALIP,RCVD_BY_IP, RCVD_IN_BLARS,RCVD_IN_BLARS_HOOPS,RCVD_IN_BLARS_SPAM autolearn=ham version=3.0.3 Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_7860_31507486.1134659656510" Precedence: bulk Lines: 32 List-Id: ruby-talk.ruby-lang.org List-Software: fml [fml 4.0.3 release (20011202/4.0.3)] List-Post: List-Owner: List-Help: List-Unsubscribe: X-Virus-Scanned: by AMaViS snapshot-20020531 ------=_Part_7860_31507486.1134659656510 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Thanks for the suggestion, Brian. The code in method_missing will use reflection to generate the shim on the fly, so I don't need to keep a list of methods that have been generated. Th= e shim is added as an instance method to the class object, so subsequent call= s will always go via the shim and not via method_missing. Cheers, -John http://www.iunknown.com ------=_Part_7860_31507486.1134659656510--