<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -220,11 +220,17 @@ $.extend(Disco.Model, {
         var association_name = association_info.association_name;
         var through_association_name = association_info.through_association_name;
         var source = association_info.source || association_name.singularize();
-        object[association_name] = function() {
+        var association = function() {
           return this[through_association_name]().collect(function(join_model) {
             return join_model[source]();
           });
         }
+        association.each = function(f) {
+          $.each(association.call(object), function(i, associated_object) {
+            f(associated_object);
+          })
+        };
+        object[association_name] = association; 
       },
 
       attach_has_one_association: function(object, association_info) {
@@ -326,14 +332,15 @@ Disco.View = function() {
 };
 
 $.extend(Disco.View, {
-  build: function(fn_or_template, init_attributes) {
+  build: function(fn_or_template, attributes) {
     var builder = new this();
     if (fn_or_template instanceof Function) {
-      fn_or_template(builder);
+      fn_or_template(builder)
+      return builder.to_view(null, attributes);
     } else {
       fn_or_template.content(builder);
+      return builder.to_view(fn_or_template, attributes);
     }
-    return builder.to_view(fn_or_template, init_attributes);
   },
 
   initialize: function() {
@@ -452,17 +459,16 @@ $.extend(Disco.View.prototype, {
     return output;
   },
 
-  to_view: function(template, init_attributes) {
+  to_view: function(template, attributes) {
     var string = this.to_string();
     if (string == &quot;&quot;) return &quot;&quot;;
 
-
     var post_processor = new Disco.View.PostProcessor($(string));
     for(var i=0; i &lt; this.doc.length; i++) {
       var element = this.doc[i];
       element.post_process(post_processor);
     }
-    post_processor.close_view(template, init_attributes);
+    post_processor.close_view(template, attributes)
     return post_processor.root_view;
   }
 });
@@ -591,13 +597,13 @@ $.extend(Disco.View.PostProcessor.prototype, {
     this.view_stack.push(view);
   },
 
-  close_view: function(template, init_attributes) {
+  close_view: function(template, attributes) {
     var current_view = this.current_view();
     if (template &amp;&amp; template.methods) {
       $.extend(current_view, template.methods);
     }
-    if (init_attributes) {
-      $.extend(current_view, init_attributes);
+    if (attributes) {
+      $.extend(current_view, attributes);
     }
     if (current_view.after_initialize) {
       current_view.after_initialize();</diff>
      <filename>lib/disco.js</filename>
    </modified>
    <modified>
      <diff>@@ -285,6 +285,17 @@ Screw.Unit(function() {
             expect(car.thoughts()).to(equal, expected_objects);
           });
         });
+
+        describe(&quot;.each&quot;, function() {
+          it(&quot;iterates over the items returned by the association&quot;, function() {
+            var eached = [];
+            car.opinions.each(function(opinion) {
+              eached.push(opinion);
+            })
+            expect(eached).to(equal, car.opinions());
+          });
+
+        });
       });
 
       describe(&quot;a belongs_to association&quot;, function() {</diff>
      <filename>spec/model_spec.js</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b41bdf33d16ed90751b7c4541e3794f4369a4661</id>
    </parent>
  </parents>
  <author>
    <name>Nathan Sobo</name>
    <email>nathansobo@gmail.com</email>
  </author>
  <url>http://github.com/nathansobo/disco/commit/a34134fcc975f5a30c062a43327746862e423fc0</url>
  <id>a34134fcc975f5a30c062a43327746862e423fc0</id>
  <committed-date>2008-06-13T17:50:09-07:00</committed-date>
  <authored-date>2008-06-13T17:50:09-07:00</authored-date>
  <message>Attributes can be passed during view construction that are available on the view before after_initialize is called</message>
  <tree>dbc8209bd3d9c5fe515d4d12e557578089fd2d0b</tree>
  <committer>
    <name>Nathan Sobo</name>
    <email>nathansobo@gmail.com</email>
  </committer>
</commit>
