Mixins for *objects*?

J

John Lam

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.iunknown.com
 
A

Austin Ziegler

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top