I'm writing some BBS-like software, and to do that I've redefined a few
of the default Kernel methods, for example:
module TelnetIO
def write x
@socket.write x
end
# ...
end
And there's a Session class that, one way or another, mixes in this
module. But, regardless of my approach, I can't access these methods
very easily outside the Session object.
The only workaround I can think of is to pass either @socket or self
to every method I use, and program ALL my other objects so that they
initialize themselves properly and mix in the proper module. Like so:
Now, I suppose I could work around this. The following might work:
...
MessageBoard.new(@socket).read_messages
...
class MessageBoard
include TelnetIO
def initialize(socket)
@socket = socket
end
# ...
def read_messages
p "No new messages."
end
end
...So, is there a cleaner or more official way to do this?
--
Nick Bensema <nickb / io.com> ICQ#2135445
==== ======= ==============
HOW HIGH CAN YOU GET? 25m 50m 75m