[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Mixins for *objects*?

John Lam

4/26/2005 1:24:00 PM

I'm trying to do something somewhat esoteric. I'm trying to mix in some additional functionality to WIN32OLE objects to avoid having to create a wrapper object that simply delegates functionality.

Imagine:

dir = WIN32OLE.connect("some moniker that returns a directory")

Let's say that I had a class that defined some helper methods like Ruby iterators:

class Dir
...
end

Is it possible to mix dir with Dir at runtime easily without adding methods at runtime etc?

Thanks
-John
http://www.iu...




1 Answer

Austin Ziegler

4/26/2005 1:29:00 PM

0

On 4/26/05, John Lam <jlam@iunknown.com> wrote:
> I'm trying to do something somewhat esoteric. I'm trying to mix in some additional functionality to WIN32OLE objects to avoid having to create a wrapper object that simply delegates functionality.
>
> Imagine:
>
> dir = WIN32OLE.connect("some moniker that returns a directory")
>
> Let's say that I had a class that defined some helper methods like Ruby iterators:
>
> class Dir
> ...
> end
>
> Is it possible to mix dir with Dir at runtime easily without adding methods at runtime etc?

Try:

dir = WIN32OLE.connect("some moniker that returns a directory")
module Dir
...
end
dir.extend(Dir)

-austin
--
Austin Ziegler * halostatue@gmail.com
* Alternate: austin@halostatue.ca