public
Description: A process execution library which doesn't suck.
Clone URL: git://github.com/codahale/ropen.git
Search Repo:
Document Ropen::Spool.
codahale (author)
Thu May 15 16:33:54 -0700 2008
commit  949057c781d8444cc4d87c5dcf915b1a065d6e89
tree    b9c89b87014c9c2884dda2cb15a8670d5433a198
parent  89febc47ed1b69caa79de6ae1b4b780ad7304866
...
1
2
3
4
 
 
 
 
 
 
 
 
 
 
 
 
5
 
 
6
7
8
9
 
10
11
12
13
14
 
 
 
15
16
17
 
18
19
20
...
1
2
 
 
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 
27
28
29
30
31
 
32
33
34
35
0
@@ -1,20 +1,35 @@
0
 require "ropen"
0
 
0
-# TODO: document me
0
-
0
+# A recorder/replayer for messages sent to a receiver. Allows clients to spool a
0
+# series of messages which can then be sent in order to a specified receiver.
0
+#
0
+# ==== Examples
0
+#
0
+# receiver = "You "
0
+# spool = Ropen::Spool.new
0
+# spool << " and me."
0
+# spool.upcase!
0
+# spool.replay(receiver)
0
+# receiver #=> "YOU AND ME."
0
+#
0
 class Ropen::Spool
0
+
0
+ # Creates a new, empty spool.
0
   def initialize
0
     @messages = []
0
   end
0
   
0
+ # Registers the method call as a message to send to the eventual receiver.
0
   def method_missing(m, *args, &block)
0
     @messages << [m, args, block]
0
   end
0
   
0
- def replay(stream)
0
+ # Sends all spooled messages to +receiver+, in order. Once a message is sent,
0
+ # it's removed from the spool.
0
+ def replay(receiver)
0
     while message = @messages.shift
0
       m, args, block = message
0
- stream.send(m, *args, &block)
0
+ receiver.send(m, *args, &block)
0
     end
0
   end
0
 end

Comments

    No one has commented yet.