sort of works with store
Matt S Trout [Wed, 20 Jan 2010 11:04:45 +0000 (11:04 +0000)]
lib/App/IdiotBox.pm
share/sql/example-data-1.0.sql

index 12393e8..c59240c 100644 (file)
@@ -16,7 +16,11 @@ use HTML::Zoom;
 
   sub slug { shift->{slug} }
   sub name { shift->{name} }
-  sub video_count { shift->{video_count} }
+  sub video_count {
+    exists $_[0]->{video_count}
+      ? $_[0]->{video_count}
+      : $_[0]->{videos}->count
+  }
   sub videos { shift->{videos} }
 
   package App::IdiotBox::Video;
index 909d18d..519a62c 100644 (file)
@@ -9,7 +9,7 @@ INSERT INTO announcements (id, made_at, bucket_slug) VALUES (
   1, '2009-12-25 09:00:00', 'lpw2009'
 );
 INSERT INTO announcements (id, made_at, bucket_slug) VALUES (
-  2, '2010-01-01 14:00:00', 'lpw2009',
+  2, '2010-01-01 14:00:00', 'lpw2009'
 );
 INSERT INTO announcements (id, made_at, bucket_slug) VALUES (
   3, '2010-01-21 01:00:00', 'opw2010'
@@ -34,6 +34,6 @@ INSERT INTO videos (
 INSERT INTO videos (
   slug, bucket_slug, name, author,announcement_id
 ) VALUES (
-  'keynote', 'opw2010', 'The Most Disgusting Word You''ll Hear'
-  'Mark Keating (mdk)', 4
+  'keynote', 'opw2010', 'The Most Disgusting Word You''ll Hear',
+  'Mark Keating (mdk)', 3
 );