Return-Path: X-Original-To: apmail-deltacloud-dev-archive@www.apache.org Delivered-To: apmail-deltacloud-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BCC8BBFD4 for ; Wed, 18 Jan 2012 09:04:23 +0000 (UTC) Received: (qmail 44187 invoked by uid 500); 18 Jan 2012 09:04:22 -0000 Delivered-To: apmail-deltacloud-dev-archive@deltacloud.apache.org Received: (qmail 44062 invoked by uid 500); 18 Jan 2012 09:04:10 -0000 Mailing-List: contact dev-help@deltacloud.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@deltacloud.apache.org Delivered-To: mailing list dev@deltacloud.apache.org Received: (qmail 44035 invoked by uid 99); 18 Jan 2012 09:04:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Jan 2012 09:04:05 +0000 X-ASF-Spam-Status: No, hits=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of mandreou@redhat.com designates 209.132.183.28 as permitted sender) Received: from [209.132.183.28] (HELO mx1.redhat.com) (209.132.183.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Jan 2012 09:04:00 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0I93c3Z031098 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 18 Jan 2012 04:03:38 -0500 Received: from [10.36.112.20] (ovpn-112-20.ams2.redhat.com [10.36.112.20]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q0I93Z9Z005360 for ; Wed, 18 Jan 2012 04:03:36 -0500 Message-ID: <4F168AE6.1040509@redhat.com> Date: Wed, 18 Jan 2012 11:03:34 +0200 From: "marios@redhat.com" User-Agent: Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20111115 Thunderbird/8.0 MIME-Version: 1.0 To: dev@deltacloud.apache.org Subject: Re: [PATCH core] CIMI: Fixed incompatibility between 1.9 and 1.8 in Proc callback References: <1326816905-40991-1-git-send-email-mfojtik@redhat.com> In-Reply-To: <1326816905-40991-1-git-send-email-mfojtik@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 ack that does it :) 13 scenarios (13 passed) 61 steps (61 passed) 0m0.426s On 17/01/12 18:15, mfojtik@redhat.com wrote: > From: Michal Fojtik > > > Signed-off-by: Michal fojtik > --- > server/lib/deltacloud/core_ext/proc.rb | 20 ++++++++++++-------- > 1 files changed, 12 insertions(+), 8 deletions(-) > > diff --git a/server/lib/deltacloud/core_ext/proc.rb b/server/lib/deltacloud/core_ext/proc.rb > index 3c443ff..1917123 100644 > --- a/server/lib/deltacloud/core_ext/proc.rb > +++ b/server/lib/deltacloud/core_ext/proc.rb > @@ -13,15 +13,19 @@ > # License for the specific language governing permissions and limitations > # under the License. > > -# Original code copied from: http://www.mattsears.com/articles/2011/11/27/ruby-blocks-as-dynamic-callbacks > -# Copyright 2011 Matt Sears. > +# Original code copied from https://gist.github.com/1417762 > +# Copyright 2011 Emmanuel Oga. > + > class Proc > + > + Callback = Struct.new(:called, :args) do > + def method_missing(name, *) > + name == :"#{called}?" || (name == called && block_given? && yield(*args)) > + end > + end > + > def callback(callable, *args) > - self === Class.new do > - method_name = callable.to_sym > - define_method(method_name) { |&block| block.nil? ? true : block.call(*args) } > - define_method("#{method_name}?") { true } > - def method_missing(method_name, *args, &block) false; end > - end.new > + call Callback.new(callable, *args) > end > + > end