<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -352,9 +352,19 @@ class &lt;&lt; Legs
     client.close!
   end
   
-  # add's a method to the 'server'
+  # add's a method to the 'server' class, bound in to that class
   def define_method(name, &amp;blk); @server_class.class_eval { define_method(name, &amp;blk) }; end
   
+  # add's a block to the 'server' class in a way that retains it's old bindings.
+  # the block will be passed the caller object, followed by the args.
+  def add_block(name, &amp;block)
+    @server_class.class_eval do
+      define_method(name) do |*args|
+        block.call caller, *args
+      end
+    end
+  end
+  
   # lets the marshaler transport symbols
   def __make_symbol(name); name.to_sym; end
   </diff>
      <filename>lib/legs.rb</filename>
    </modified>
    <modified>
      <diff>@@ -165,11 +165,14 @@ class TestLegsObject &lt; Test::Unit::TestCase
    assert_equal(true, $bidirectional_worked)
   end
   
-  # makes sure the define_method thingo works for adding blocks to Legs
+  # makes sure the block adding thingos work
   def test_adding_block
-    bound_var = 'Ladedadedah'
+    @bound_var = bound_var = 'Ladedadedah'
     Legs.define_method(:defined_meth) { bound_var }
     assert_equal(bound_var, Remote.defined_meth)
+    
+    Legs.add_block(:unbound_meth) { @bound_var }
+    assert_equal(bound_var, Remote.unbound_meth)
   end
   
   # this is to make sure we can run the start method a ton of times without bad side effects</diff>
      <filename>test/test_legs.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>437eed45bdb99cdb460a65822e15c6c507cec484</id>
    </parent>
  </parents>
  <author>
    <name>Jenna Fox</name>
    <email>blueberry@creativepony.com</email>
  </author>
  <url>http://github.com/Bluebie/legs/commit/facec1408785fa0ca56abdd77f7d54e3a6882a7e</url>
  <id>facec1408785fa0ca56abdd77f7d54e3a6882a7e</id>
  <committed-date>2008-07-25T01:28:15-07:00</committed-date>
  <authored-date>2008-07-25T01:28:15-07:00</authored-date>
  <message>Now we also have an 'add_block' method on the Legs class, which lets you do Legs.add_block(:ponies?) { @awesomeness } and have it add that block in to Legs much like define_method does, but keeping the block unbound to the legs server class. This means @awesomeness and 'self' will refer to the instance variable in the place where you called Legs.add_block, and not to the legs server as it does when using Legs.define_method or Legs.start. This should be really useful for stuff like Shoes apps, where you want remote requests to have local actions in a specific scope.</message>
  <tree>e9e5d6378a698dca3589e70f9783d0d17052e1ac</tree>
  <committer>
    <name>Jenna Fox</name>
    <email>blueberry@creativepony.com</email>
  </committer>
</commit>
