From: shasckaw Date: 2004-02-09T06:27:16+09:00 Subject: Re: role pattern lib for ruby Robert Klemme wrote: > "shasckaw" schrieb im Newsbeitrag > news:401ee616$0$320$ba620e4c@news.skynet.be... > >>Thansk for the link, it looks interesting but it is perhaps too complex >>for what I intend to do. But I can give it a try... well, I'd be happy >>to try it but there isn't any files in the package, and project activity >>is near to death. I'll try to get more info about it, but I haven't much >>hope. >> >>If anyone has another solution, please help me! > > > Depending on what you need to do it might even be built into the language > already. If you only need to add roles over time you could define some > modules for the roles and add them as needed: > > irb(main):001:0> class Foo;end > => nil > irb(main):002:0> f=Foo.new > => # > irb(main):003:0> f.respond_to? :inject > => false > irb(main):004:0> f.extend Enumerable > => # > irb(main):005:0> f.respond_to? :inject > => true > > Other than that SimpleDelegator might help you as well: > http://www.rubycentral.com/book/lib_patterns.html > > robert > > I'll try that way, thanks for the advices, Lio