🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.ruby
Article #188

Re: Ruby i dekorator

#188
From: Marcin Mielżyński
Date: Thu, 07 Sep 2006 17:36
33 lines
1537 bytes
to chyba najprościej tak:

class Base

     def render_to_string(options = nil, &block)
         # oryginalna czarna skrzynka
     end

end


# powtórne otwarcie klasy

class Base
     alias :orig_render_to_string render_to_string

     def render_to_string(*args, &blk)

         result = orig_render_to_string(*args,&blk)
         # ...
         result
     end
end

A.new.render_to_string


myślałem że chodzi o bardziej 'generyczne' rozwiązanie ;)

W 2.0 będą kombinatory :pre :post i :around


lopex
Technical Details
Message-ID: <edplas$47s$1@news.onet.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!news.onet.pl!not-for-mail
References: <re7vnvdwaxef.1xsf47isecttl$.dlg@40tude.net> <edp0jp$ph2$1@news.onet.pl> <1b5oye9z0x1aq.n67fdxozbl7i.dlg@40tude.net> <edp53n$b6v$1@news.onet.pl> <1x2rocd4cjsfx.1pa1f7xfso7pe.dlg@40tude.net>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!news.onet.pl!not-for-mail
From: Marcin Mielżyński <lopx@gazeta.pl>
Newsgroups: pl.comp.lang.ruby
Subject: Re: Ruby i dekorator
Date: Thu, 07 Sep 2006 19:36:22 +0200
Organization: Onet.pl
Lines: 33
Message-ID: <edplas$47s$1@news.onet.pl>
References: <re7vnvdwaxef.1xsf47isecttl$.dlg@40tude.net> <edp0jp$ph2$1@news.onet.pl> <1b5oye9z0x1aq.n67fdxozbl7i.dlg@40tude.net> <edp53n$b6v$1@news.onet.pl> <1x2rocd4cjsfx.1pa1f7xfso7pe.dlg@40tude.net>
NNTP-Posting-Host: chello087207016023.chello.pl
Mime-Version: 1.0
X-Trace: news.onet.pl 1157650588 4348 87.207.16.23 (7 Sep 2006 17:36:28 GMT)
X-Complaints-To: usenet@news.onet.pl
NNTP-Posting-Date: Thu, 7 Sep 2006 17:36:28 +0000 (UTC)
X-Sender: 5Da2qcG7AWj7WISFX859Php/OS6q4VnB
In-Reply-To: <1x2rocd4cjsfx.1pa1f7xfso7pe.dlg@40tude.net>
User-Agent: Thunderbird 1.5.0.5 (Windows/20060719)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit