use the more idiomatic Schema instead of DBIC
Arthur Axel 'fREW' Schmidt [Sat, 1 May 2010 08:51:45 +0000 (03:51 -0500)]
slideshow.html

index c058356..68f2a07 100644 (file)
@@ -403,8 +403,8 @@ my @books = $book_model->search({
 
    <div class="slide">
       <h1>splitting logic cleanly</h1>
-      <p>Foo::DBIC::Result::Foo = an individual row</p>
-      <p>Foo::DBIC::ResultSet::Foo = searches / results</p>
+      <p>Foo::Schema::Result::Foo = an individual row</p>
+      <p>Foo::Schema::ResultSet::Foo = searches / results</p>
    </div>
 
    <div class="slide">
@@ -419,8 +419,8 @@ my @books = $book_model-&gt;search({
 
    <div class="slide">
       <h1>Schema::Loader</h1>
-<pre>Foo::DBIC::Result::Authors-&gt;table("authors");
-Foo::DBIC::Result::Authors-&gt;add_columns(
+<pre>Foo::Schema::Result::Authors-&gt;table("authors");
+Foo::Schema::Result::Authors-&gt;add_columns(
    id =&gt; {
       data_type     =&gt; "INT",
       default_value =&gt; undef,
@@ -434,13 +434,13 @@ Foo::DBIC::Result::Authors-&gt;add_columns(
       size          =&gt; 255,
    },
 );
-Foo::DBIC::Result::Authors-&gt;set_primary_key("id");</pre>
+Foo::Schema::Result::Authors-&gt;set_primary_key("id");</pre>
    </div>
 
    <div class="slide">
       <h1>Schema::Loader</h1>
-<pre>Foo::DBIC::Result::Books->table("books");
-Foo::DBIC::Result::Books->add_columns(
+<pre>Foo::Schema::Result::Books->table("books");
+Foo::Schema::Result::Books->add_columns(
    id =&gt; {
       data_type     =&gt; "INT",
       default_value =&gt; undef,
@@ -460,15 +460,15 @@ Foo::DBIC::Result::Books->add_columns(
       size          =&gt; 8
    },
 );
-Foo::DBIC::Result::Books-&gt;set_primary_key("id");</pre>
+Foo::Schema::Result::Books-&gt;set_primary_key("id");</pre>
    </div>
 
    <div class="slide">
       <h1>Schema::Loader</h1>
-<pre>Foo::DBIC::Result::Authors-&gt;has_many(books =&gt; "Foo::DBIC::Books",
+<pre>Foo::Schema::Result::Authors-&gt;has_many(books =&gt; "Foo::Schema::Books",
    { "foreign.author" =&gt; "self.id" });
 
-Foo::DBIC::Result::Books-&gt;belongs_to(author =&gt; "Foo::DBIC::Authors",
+Foo::Schema::Result::Books-&gt;belongs_to(author =&gt; "Foo::Schema::Authors",
    { id =&gt; "author" });</pre>
    </div>
 
@@ -483,15 +483,15 @@ INSERT INTO books (author, title)
 
    <div class="slide">
       <h1>overloading</h1>
-<pre>Foo::DBIC::Result::Books
-Foo::DBIC::ResultSet::Books
-Foo::DBIC::Result::Authors
-Foo::DBIC::ResultSet::Books</pre>
+<pre>Foo::Schema::Result::Books
+Foo::Schema::ResultSet::Books
+Foo::Schema::Result::Authors
+Foo::Schema::ResultSet::Books</pre>
    </div>
 
    <div class="slide">
       <h1>Result::</h1>
-<pre>package Foo::DBIC::Result::Books;
+<pre>package Foo::Schema::Result::Books;
 use base 'DBIx::Class';
 use strict;
 use warnings;
@@ -517,7 +517,7 @@ sub isbn {
 
    <div class="slide">
       <h1>Result:: (inflating)</h1>
-<pre>package Foo::DBIC::Result::Books;
+<pre>package Foo::Schema::Result::Books;
 use base 'DBIx::Class';
 use strict;
 use warnings;
@@ -535,7 +535,7 @@ __PACKAGE__-&gt;<strong>inflate_column</strong>(
 
    <div class="slide">
       <h1>Result:: (inflating)</h1>
-<pre>package Foo::DBIC::Result::Books;
+<pre>package Foo::Schema::Result::Books;
 use base 'DBIx::Class';
 use strict;
 use warnings;
@@ -569,7 +569,7 @@ print $date_published-&gt;month_abbr;</pre>
 
    <div class="slide">
       <h1>ResultSets::</h1>
-<pre>package Foo::DBIC::ResultSet::Books;
+<pre>package Foo::Schema::ResultSet::Books;
 use base 'DBIx::Class::ResultSet';
 sub the_ultimate_books {
    my $self = shift;
@@ -585,7 +585,7 @@ sub by_author {
 
    <div class="slide">
       <h1>ResultSets::</h1>
-<pre>package Foo::DBIC::<strong>ResultSet::Books</strong>;
+<pre>package Foo::Schema::<strong>ResultSet::Books</strong>;
 use base '<strong>DBIx::Class::ResultSet</strong>';
 sub the_ultimate_books {
    my $self = shift;
@@ -601,7 +601,7 @@ sub by_author {
 
    <div class="slide">
       <h1>ResultSets::</h1>
-<pre>package Foo::DBIC::ResultSet::Books;
+<pre>package Foo::Schema::ResultSet::Books;
 use base 'DBIx::Class::ResultSet';
 sub the_ultimate_books {
    my $self = shift;
@@ -617,17 +617,17 @@ sub by_author {
 
    <div class="slide">
       <h1>ResultSets::</h1>
-<pre>use Foo::DBIC;
-my $book_model = Foo::DBIC-&gt;resultset('Books');
+<pre>use Foo::Schema;
+my $book_model = Foo::Schema-&gt;resultset('Books');
 my $book_rs    = $book_model-&gt;the_ultimate_books;
 my @books      = $book_rs-&gt;all;</pre>
    </div>
 
    <div class="slide">
       <h1>ResultSets::chaining</h1>
-<pre>use Foo::DBIC;
-my $book_model   = Foo::DBIC-&gt;resultset('Books');
-my $author_model = Foo::DBIC-&gt;resultset('Authors');
+<pre>use Foo::Schema;
+my $book_model   = Foo::Schema-&gt;resultset('Books');
+my $author_model = Foo::Schema-&gt;resultset('Authors');
 my $author       = $author_model-&gt;search({ name =&gt; 'Douglas Adams' })-&gt;single;
 my $book_rs      = $book_model-&gt;the_ultimate_books-&gt;by_author($author);
 my @books        = $book_rs-&gt;all;</pre>
@@ -669,7 +669,7 @@ my @books = $rs-&gt;all;</pre>
 
    <div class="slide">
       <h1>overloading before new record</h1>
-      <pre>package Foo::DBIC::Result::Authors;
+      <pre>package Foo::Schema::Result::Authors;
 use base 'DBIx::Class';
 
 sub new {
@@ -731,9 +731,9 @@ ALTER TABLE `books` DROP `author`</pre>
 
    <div class="slide">
       <h1>has_many</h1>
-<pre>package Foo::DBIC::<strong>Result::Books</strong>;
+<pre>package Foo::Schema::<strong>Result::Books</strong>;
 
-__PACKAGE__-&gt;has_many( author_and_books =&gt; "Foo::DBIC::Result::AuthorAndBooks",
+__PACKAGE__-&gt;has_many( author_and_books =&gt; "Foo::Schema::Result::AuthorAndBooks",
     { "foreign.book" =&gt; "self.id" },
 );
 
@@ -742,11 +742,11 @@ __PACKAGE__-&gt;has_many( author_and_books =&gt; "Foo::DBIC::Result::AuthorAndBo
 
    <div class="slide">
       <h1>has_many</h1>
-<pre>package Foo::DBIC::<strong>Result::Books</strong>;
+<pre>package Foo::Schema::<strong>Result::Books</strong>;
 
 __PACKAGE__-&gt;has_many(
 author_and_books =&gt; <strong># name of accessor</strong>
-"Foo::DBIC::Result::AuthorAndBooks", <strong># related class</strong>
+"Foo::Schema::Result::AuthorAndBooks", <strong># related class</strong>
     { "foreign.book" =&gt; "self.id" } <strong># Relationship (magic often works if not
                                         # specified, but avoid!)</strong>
 );
@@ -759,11 +759,11 @@ author_and_books =&gt; <strong># name of accessor</strong>
 
    <div class="slide">
       <h1>belongs_to</h1>
-<pre>package Foo::DBIC::<strong>Result::AuthorAndBooks</strong>;
+<pre>package Foo::Schema::<strong>Result::AuthorAndBooks</strong>;
 
 __PACKAGE__-&gt;belongs_to(
    book =&gt; <strong># Accessor name</strong>
-   "Foo::DBIC::Result::Books", <strong># Related class</strong>
+   "Foo::Schema::Result::Books", <strong># Related class</strong>
    { id =&gt; "book" } <strong># relationship</strong>
 );
 </pre>
@@ -783,7 +783,7 @@ __PACKAGE__-&gt;belongs_to(
 
    <div class="slide">
       <h1>many_to_many</h1>
-      <pre>package Foo::DBIC::<strong>Result::Books</strong>;
+      <pre>package Foo::Schema::<strong>Result::Books</strong>;
 use base 'DBIx::Class';
 
 __PACKAGE__-&gt;many_to_many(
@@ -797,7 +797,7 @@ __PACKAGE__-&gt;many_to_many(
 
    <div class="slide">
       <h1>many_to_many</h1>
-      <pre>package Foo::DBIC::<strong>Result::Books</strong>;
+      <pre>package Foo::Schema::<strong>Result::Books</strong>;
 use base 'DBIx::Class';
 
 __PACKAGE__-&gt;many_to_many(
@@ -811,7 +811,7 @@ __PACKAGE__-&gt;many_to_many(
 
    <div class="slide">
       <h1>many_to_many</h1>
-      <pre>package Foo::DBIC::Result::Authors;
+      <pre>package Foo::Schema::Result::Authors;
 use base 'DBIx::Class';
 
 __PACKAGE__-&gt;many_to_many(
@@ -829,9 +829,9 @@ __PACKAGE__-&gt;many_to_many(
       <h1>using many_to_many</h1>
       <pre>#!/usr/bin/perl
 
-use Foo::DBIC;
+use Foo::Schema;
 
-my $author_model = Foo::DBIC-&gt;resultset('Authors');
+my $author_model = Foo::Schema-&gt;resultset('Authors');
 my $author       = $author_model-&gt;search({
    name =&gt; 'Douglas Adams',
 })-&gt;single;
@@ -875,12 +875,12 @@ $book-&gt;add_to_authors($author_2);</pre>
 
    <div class="slide">
       <h1>error messages</h1>
-      <pre>DBIx::Class::Schema::Loader::connection(): Failed to load external class definition for 'Foo::DBIC::Result::Authors': Can't locate object method "many_to_many" via package "Foo::DBIC::Result::Author" at lib/Foo/DBIC/Result/Authors.pm line 9.Compilation failed in require at /Library/Perl/5.8.8/DBIx/Class/Schema/Loader/Base.pm line 292.</pre>
+      <pre>DBIx::Class::Schema::Loader::connection(): Failed to load external class definition for 'Foo::Schema::Result::Authors': Can't locate object method "many_to_many" via package "Foo::Schema::Result::Author" at lib/Foo/Schema/Result/Authors.pm line 9.Compilation failed in require at /Library/Perl/5.8.8/DBIx/Class/Schema/Loader/Base.pm line 292.</pre>
    </div>
 
    <div class="slide">
       <h1>error messages</h1>
-   <pre>DBIx::Class::Schema::Loader::connection(): Failed to load external class definition for 'Foo::DBIC::Result::Authors': Can't locate object method "many_to_many" via package "Foo::DBIC::<strong>Result::Author</strong>" at lib/Foo/DBIC/<strong>Result/Authors.pm</strong> line 9.Compilation failed in require at /Library/Perl/5.8.8/DBIx/Class/Schema/Loader/Base.pm line 292.</pre>
+   <pre>DBIx::Class::Schema::Loader::connection(): Failed to load external class definition for 'Foo::Schema::Result::Authors': Can't locate object method "many_to_many" via package "Foo::Schema::<strong>Result::Author</strong>" at lib/Foo/Schema/<strong>Result/Authors.pm</strong> line 9.Compilation failed in require at /Library/Perl/5.8.8/DBIx/Class/Schema/Loader/Base.pm line 292.</pre>
    </div>
 
    <div class="slide">
@@ -911,13 +911,13 @@ $book-&gt;add_to_authors($author_2);</pre>
    <div class="slide">
       <h1>Catalyst</h1>
       <pre>package Your::App::Model::<strong>Foo</strong>;
-use base qw(<strong>Catalyst::Model::DBIC::Schema</strong>);
+use base qw(<strong>Catalyst::Model::Schema::Schema</strong>);
 
 use strict;
 use warnings;
 
 __PACKAGE__-&gt;config(
-  schema_class =&gt; '<strong>Foo::DBIC</strong>',
+  schema_class =&gt; '<strong>Foo::Schema</strong>',
 );
 
 1;</pre>
@@ -929,7 +929,7 @@ __PACKAGE__-&gt;config(
 <pre>sub action_name : Local {
   my ($self, $c) = @_;
 
-  my $model = $c-&gt;model('DBIC::Foo');
+  my $model = $c-&gt;model('Schema::Foo');
   my $author_model = $model-&gt;resultset('Authors');
 
 }