<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -2,6 +2,8 @@ module DataObjects
   # Abstract class to read rows from a query result
   class Reader
 
+    include Enumerable
+
     # Return the array of field names
     def fields
       raise NotImplementedError.new
@@ -27,5 +29,23 @@ module DataObjects
       raise NotImplementedError.new
     end
 
+    # Yield each row to the given block as a struct
+    def each
+      begin
+        while next!
+          yield struct.new(*values)
+        end
+      ensure
+        close
+        self
+      end
+    end
+
+    private
+
+    def struct
+      @struct ||= Struct.new(*fields.map {|f| f.to_sym})
+    end
+
   end
 end</diff>
      <filename>data_objects/lib/data_objects/reader.rb</filename>
    </modified>
    <modified>
      <diff>@@ -153,4 +153,31 @@ share_examples_for 'a Reader' do
 
   end
 
+  it { @reader.should respond_to(:values) }
+
+  describe 'each' do
+
+    it 'should yield each row to the block' do
+      rows_yielded = 0
+      @reader.each do |row|
+        row.should respond_to(:[])
+        row.should respond_to(:name)
+        row.should respond_to(:code)
+
+        row.size.should == 2
+
+        row.name.should be_a(String)
+        row.code.should be_a(String)
+        row[:name].should be_a(String)
+        row[:code].should be_a(String)
+        row[0].should be_a(String)
+        row[1].should be_a(String)
+
+        rows_yielded += 1
+      end
+      rows_yielded.should == 15
+    end
+
+  end
+
 end</diff>
      <filename>data_objects/lib/data_objects/spec/reader_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,10 +9,13 @@ describe DataObjects::Reader do
 
     reader = command.execute_reader
 
+    reader.should be_a(Enumerable)
+
     reader.should respond_to(:close)
     reader.should respond_to(:next!)
     reader.should respond_to(:values)
     reader.should respond_to(:fields)
+    reader.should respond_to(:each)
 
     connection.close
   end</diff>
      <filename>data_objects/spec/reader_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -46,10 +46,10 @@ CONFIG = OpenStruct.new
 CONFIG.scheme    = 'postgres'
 CONFIG.user      = ENV['DO_POSTGRES_USER'] || 'postgres'
 CONFIG.pass      = ENV['DO_POSTGRES_PASS'] || ''
-CONFIG.user_info = unless CONFIG.user == 'postgres' &amp;&amp; CONFIG.pass.empty?
+CONFIG.user_info = unless CONFIG.pass.empty?
   &quot;#{CONFIG.user}:#{CONFIG.pass}@&quot;
 else
-  ''
+  &quot;#{CONFIG.user}@&quot;
 end
 CONFIG.host      = ENV['DO_POSTGRES_HOST'] || 'localhost'
 CONFIG.port      = ENV['DO_POSTGRES_PORT'] || '5432'</diff>
      <filename>do_postgres/spec/spec_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>2f97433d681fdb5185305c57ae96a41a385d85f2</id>
    </parent>
  </parents>
  <author>
    <name>Dirkjan Bussink</name>
    <email>d.bussink@gmail.com</email>
  </author>
  <url>http://github.com/datamapper/do/commit/d1381d7f09d22ca11341a1adbfbc6f530208fb32</url>
  <id>d1381d7f09d22ca11341a1adbfbc6f530208fb32</id>
  <committed-date>2009-10-27T13:12:13-07:00</committed-date>
  <authored-date>2009-10-27T13:12:13-07:00</authored-date>
  <message>Add enumerable support to DO using structs</message>
  <tree>63598d10d117e2ff4a18a1b057a5bfda69bf2716</tree>
  <committer>
    <name>Dirkjan Bussink</name>
    <email>d.bussink@gmail.com</email>
  </committer>
</commit>
