<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -2,10 +2,15 @@
 module MethodChain
 
 private
-
-  #   arg = Message | Code
-  #   Message = Symbol | [Symbol, *arguments]
-  #   Code.to_proc = Proc
+# public MethodChain methods depend on these private methods
+# with the module-import gem you choose which public methods you want to import
+# and by default private methods will be included
+
+  # A middleman for passing code as data in 2 different ways
+  # * use a Symbol or an Array as the argument list for send
+  # * evaluate a Proc-like object with yield_or_eval
+  #
+  # Symbol | [Method, *MethodArguments] | (to_proc -&gt; Proc)
   def send_as_function arg
     case arg
     when Symbol then __send__ arg
@@ -14,13 +19,14 @@ private
     end
   end
 
-  # send_as_function with multiple args, returns self
+  # invoke send_as_function multiple times, returns self
+  # *Message -&gt; self
   def send_as_functions *args
     args.each {|arg| send_as_function arg}
     self
   end
 
-  # yield or instance_eval based on the block arity
+  # yield self or instance_eval based on the block arity
   def yield_or_eval &amp;block
     case block.arity
     # ruby bug for -1
@@ -39,23 +45,23 @@ public
     self
   end
 
-  # method chaining with a guard.
+  # method chaining with a +guard+.
   # If no guard block is given then guard against nil and false
   def chain *messages, &amp;guard
     return self if messages.empty? or not(
       (block_given? ? (yield_or_eval(&amp;guard)) : self))
 
-    (send_as_function (messages.shift)).chain(*messages, &amp;guard)
+    (send_as_function messages.shift).chain(*messages, &amp;guard)
   end
 
-  # return self if self or a guard evaluates to false,
+  # return self if self or any of the +guards+ evaluate to false,
   # otherwise return the evaluation of the block
   def then *guards, &amp;block
     if guards.empty? 
       return self if not self
     else
       guards.each do |cond|
-        return self if not send_as_function(cond)
+        return self if not (send_as_function cond)
       end
     end
 
@@ -76,7 +82,7 @@ public
     block_given? ? yield_or_eval(&amp;block) : self
   end
 
-  # with no guards, is equivalent to self &amp;&amp; yield_or_eval(&amp;block) &amp;&amp; self
+  # with no +guards+, is equivalent to self &amp;&amp; yield_or_eval(&amp;block) &amp;&amp; self
   # same as: &lt;tt&gt;self.then(*guards, &amp;block) &amp;&amp; self&lt;/tt&gt;
   def and *guards, &amp;block
     if guards.empty? 
@@ -90,7 +96,7 @@ public
     block_given? ? (yield_or_eval(&amp;block) &amp;&amp; self) : self
   end
 
-  # with no guards, is equivalent to &lt;tt&gt;self || (yield_or_eval(&amp;block) &amp;&amp; self)&lt;/tt&gt;
+  # with no +guards+, is equivalent to &lt;tt&gt;self || (yield_or_eval(&amp;block) &amp;&amp; self)&lt;/tt&gt;
   # same as: &lt;tt&gt;self.else(*guards, &amp;block) &amp;&amp; self&lt;/tt&gt;
   def or *guards, &amp;block
     if guards.empty? </diff>
      <filename>lib/methodchain/not-included.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,35 +1,37 @@
-require File.dirname(__FILE__) + '/../lib/methodchain'
+__DIR__ = File.dirname(__FILE__)
+require __DIR__ + '/match_each'
+require __DIR__ + '/../lib/methodchain'
 
 #TODO
 # test message sending with #and and #or using shared_examples_for
 
 class Object; def return_nil() nil end end
 
-shared_examples_for &quot;self-returning method&quot; do
+shared_examples_for &quot;method that returns self when no non-block paramaters are given&quot; do
   it 'should returns self when no arguments are given' do
-    @objects.each { |obj| obj.send(@meth).should == obj }
+    @objects.each {|obj| obj.send(@meth).should == obj }
   end
 
   it 'should returns self when a block with no arguments is given' do
-    @objects.each { |obj| obj.send(@meth) {}.should == obj }
+    @objects.each {|obj| obj.send(@meth) {}.should == obj }
   end
 
   it 'should return self when a block with one argument is given' do
-    @objects.each { |obj| obj.send(@meth) {|_|}.should == obj }
+    @objects.each {|obj| obj.send(@meth) {|_|}.should == obj }
   end
 end
 
 
 describe 'any object' do
   before do
-    @trues = [true,'a']
+    @trues = [true,'a',1]
     @falses = [false,nil]
     @objects = @trues + @falses
   end
 
   describe &quot;#chain&quot; do
     before { @meth = :chain }
-    it_should_behave_like &quot;self-returning method&quot;
+    it_should_behave_like &quot;method that returns self when no non-block paramaters are given&quot;
 
     it &quot;should not evaluate a block when just a block is given&quot; do
       @objects.each { |obj| obj.chain {fail}.should == obj }
@@ -42,12 +44,12 @@ describe 'any object' do
 
     it &quot;should send procs&quot; do
       @trues.should  each {|obj| obj.chain(lambda{|o| o.class}).should == obj.class }
-      @falses.should  each {|obj| obj.chain(lambda{|o| o.class}).should == obj }
+      @falses.should each {|obj| obj.chain(lambda{|o| o.class}).should == obj }
     end
 
     it &quot;should send an array as a message with arguments&quot; do
-      @trues.should  each {|obj| obj.chain([:class]).should == obj.class }
-      @falses.should each {|obj| obj.chain([:class]).should == obj }
+      @trues.should  each {|obj| obj.chain([:class], :to_s).should == obj.class.to_s }
+      @falses.should each {|obj| obj.chain([:class], :to_s).should == obj }
     end
 
     it &quot;should yield self to a block and return self if block has one argument&quot; do
@@ -71,7 +73,7 @@ describe 'any object' do
 
   describe &quot;#tap&quot; do
     before { @meth = :tap }
-    it_should_behave_like &quot;self-returning method&quot;
+    it_should_behave_like &quot;method that returns self when no non-block paramaters are given&quot;
 
     it &quot;should yield self to a block and return self if block has one argument&quot; do
       @objects.should( each do |o|
@@ -138,7 +140,7 @@ describe &quot;#tap&quot; do
     [].tap(lambda{ push('a'); 'blah' }).should == ['a']
   end
   it &quot;#tap should send a method to itself&quot; do
-    [1, 2, 3, 4, 5].tap { |arr| arr.pop }.should == [1, 2, 3, 4]
+    [1, 2, 3, 4, 5].tap {|arr| arr.pop }.should == [1, 2, 3, 4]
     [1, 2, 3, 4, 5].tap(:pop).should == [1, 2, 3, 4]
     [1, 2, 3, 4, 5].tap(:pop) {|arr| arr.pop}.should == [1, 2, 3]
   end
@@ -148,7 +150,7 @@ describe &quot;#tap&quot; do
 end
 
 
-shared_examples_for 'then/else' do
+shared_examples_for 'then/else and/or' do
   it &quot;should return self if no conditions are given and self evaluates to #{!@bool}&quot; do
     @vals.should( each do |val|
       val.send(@opp).should == val
@@ -168,15 +170,18 @@ shared_examples_for 'then/else' do
     end )
   end
 
-  it &quot;if self evaluates to #{@bool} ##{@same} should yield self to a block if one is given, and return that block's value&quot; do
+  it &quot;if self evaluates to #{!@bool} ##{@opp} should yield self to a block if one is given, and return that block's value&quot; do
     @vals.should( each do |val|
-      val.send(@same)   {|v| v.should == val; 'foo'}.should == 'foo'
+      val.send(@opp) {|v| v.should == val; 'foo'}.should == val
     end )
   end
+end
 
-  it &quot;if self evaluates to #{!@bool} ##{@opp} should yield self to a block if one is given, and return that block's value&quot; do
+
+shared_examples_for 'then/else' do
+  it &quot;if self evaluates to #{@bool} ##{@same} should yield self to a block if one is given, and return that block's value&quot; do
     @vals.should( each do |val|
-      val.send(@opp) {|v| v.should == val; 'foo'}.should == val
+      val.send(@same)   {|v| v.should == val; 'foo'}.should == 'foo'
     end )
   end
 
@@ -193,21 +198,50 @@ end
 
 
 describe 'true values' do
-  it_should_behave_like 'then/else'
-
   before do
-    @vals = ['a',true]
+    @vals = @trues = ['a',true]
     @bool = !!@vals.first
-    @same, @opp = @bool ? [:then,:else] : [:else,:then]
+  end
+
+  describe 'then/else' do
+    it_should_behave_like 'then/else and/or'
+    it_should_behave_like 'then/else'
+
+    before do
+      @same, @opp = @bool ? [:then,:else] : [:else,:then]
+    end
+  end
+
+  describe 'and/or' do
+    it_should_behave_like 'then/else and/or'
+
+    before do
+      @same, @opp = @bool ? [:and,:or] : [:or,:and]
+    end
   end
 end
 
-describe 'false values' do
-  it_should_behave_like 'then/else'
 
+describe 'false values' do
   before do
-    @vals = [nil,false]
+    @vals = @falses = [nil,false]
     @bool = !!@vals.first
-    @same, @opp = @bool ? [:then,:else] : [:else,:then]
+  end
+
+  describe 'then/else' do
+    it_should_behave_like 'then/else and/or'
+    it_should_behave_like 'then/else'
+
+    before do
+      @same, @opp = @bool ? [:then,:else] : [:else,:then]
+    end
+  end
+
+  describe 'and/or' do
+    it_should_behave_like 'then/else and/or'
+
+    before do
+      @same, @opp = @bool ? [:and,:or] : [:or,:and]
+    end
   end
 end</diff>
      <filename>spec/methodchain_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>fac0833a104513ad6905fa4321e106dafd1a0643</id>
    </parent>
  </parents>
  <author>
    <name>Greg Weber</name>
    <email>greg@grubtop.(none)</email>
  </author>
  <url>http://github.com/gregwebs/methodchain/commit/6dc628681807d25065021e1427540a4f11913a9c</url>
  <id>6dc628681807d25065021e1427540a4f11913a9c</id>
  <committed-date>2008-11-01T18:41:43-07:00</committed-date>
  <authored-date>2008-11-01T18:41:43-07:00</authored-date>
  <message>updated documentation and specs</message>
  <tree>db4607ded697823cb689f7ac12e67a7f0b643340</tree>
  <committer>
    <name>Greg Weber</name>
    <email>greg@grubtop.(none)</email>
  </committer>
</commit>
