<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>spec/prepare.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,4 @@
 .DS_Store
 pkg
 doc
+*.sqlite3</diff>
      <filename>.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,17 @@
 module ScopeBuilder
-  class Builder &lt; ActiveRecord::NamedScope::Scope
+  class Builder
+    def initialize(proxy_scope)
+      @proxy_scope = proxy_scope
+    end
+    
+    def method_missing(method, *args, &amp;block)
+      result = @proxy_scope.send(method, *args, &amp;block)
+      if result.class == ActiveRecord::NamedScope::Scope
+        @proxy_scope = result
+        self
+      else
+        result
+      end
+    end
   end
 end</diff>
      <filename>lib/scope_builder/builder.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 module ScopeBuilder
   module ModelAdditions
     def scope_builder
-      Builder.new(self, {})
+      Builder.new(scoped({}))
     end
   end
 end</diff>
      <filename>lib/scope_builder/model_additions.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,11 +1,16 @@
 require File.dirname(__FILE__) + '/../spec_helper'
 
 class Product &lt; ActiveRecord::Base
-  named_scope :released
+  named_scope :released, :conditions =&gt; ['released=?', true]
 end
 
 describe ScopeBuilder::Builder do
   before(:each) do
+    Product.delete_all
+    Product.create!(:name =&gt; 'a', :released =&gt; true)
+    Product.create!(:name =&gt; 'b', :released =&gt; false)
+    Product.create!(:name =&gt; 'c', :released =&gt; true)
+    
     @builder = Product.scope_builder
   end
   
@@ -16,4 +21,22 @@ describe ScopeBuilder::Builder do
   it &quot;should allow named scopes to be called through it&quot; do
     @builder.released.proxy_options.should == Product.released.proxy_options
   end
+  
+  it &quot;should remember scope calls&quot; do
+    @builder.released
+    @builder.proxy_options.should == Product.released.proxy_options
+  end
+  
+  it &quot;should build up scopes&quot; do
+    @builder.released.scoped(:limit =&gt; 1)
+    @builder.scoped(:offset =&gt; 1)
+    @builder.all.should == Product.released.scoped(:limit =&gt; 1, :offset =&gt; 1).all
+  end
+  
+  it &quot;should enumerate like an array&quot; do
+    products = Product.find(:all)
+    @builder.each_with_index do |product, index|
+      product.should == products[index]
+    end
+  end
 end</diff>
      <filename>spec/scope_builder/builder_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,6 +6,12 @@ require 'action_controller'
 require 'action_view'
 require File.dirname(__FILE__) + '/../lib/scope_builder.rb'
 
+# setup database adapter
+ActiveRecord::Base.establish_connection({
+  :adapter =&gt; &quot;sqlite3&quot;, 
+  :dbfile =&gt; File.dirname(__FILE__) + &quot;/test.sqlite3&quot; 
+})
+
 Spec::Runner.configure do |config|
   config.mock_with :mocha
 end</diff>
      <filename>spec/spec_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>spec/scope_builder/model_additions_spec.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>a0c33fce5a5276e8ab10a4164069a688ac00eaea</id>
    </parent>
  </parents>
  <author>
    <name>Ryan Bates</name>
    <email>ryan@railscasts.com</email>
  </author>
  <url>http://github.com/ryanb/scope-builder/commit/dbfa699ca9c22a7467e6f8c10fa3b9e51591d27e</url>
  <id>dbfa699ca9c22a7467e6f8c10fa3b9e51591d27e</id>
  <committed-date>2008-06-26T09:27:18-07:00</committed-date>
  <authored-date>2008-06-26T09:27:18-07:00</authored-date>
  <message>rewriting builder to act as a simple delegator</message>
  <tree>b3b6b08ec8a34cf7003fee3f73513d634591b13e</tree>
  <committer>
    <name>Ryan Bates</name>
    <email>ryan@railscasts.com</email>
  </committer>
</commit>
