WWW::Battrick

Check-in [26473481a3]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:create schema
Timelines: family | ancestors | descendants | both | develop
Files: files | file ages | folders
SHA1:26473481a3463bfe2687dacfa3ec206c3e94f919
User & Date: erezs@teleweb.co.il 2011-09-07 15:40:12
Context
2011-09-07
15:51
login skeleton check-in: 7e55dbaf10 user: erezs@teleweb.co.il tags: develop
15:40
create schema check-in: 26473481a3 user: erezs@teleweb.co.il tags: develop
15:24
schemas check-in: d7a06f8d00 user: erezs@teleweb.co.il tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to lib/WWW/Battrick.pm.

     1      1   use strict;
     2      2   use warnings;
     3      3   package WWW::Battrick;
            4  +
            5  +use WWW::Battrick::Schema;
            6  +
            7  +use Moose;
            8  +
            9  +has schema => (
           10  +    is => 'ro',
           11  +    isa => 'DBIx::Class::Schema',
           12  +    lazy_build => 1,
           13  +);
           14  +
           15  +sub _build_schema {
           16  +    my $self = shift;
           17  +
           18  +    unless (opendir my $DIR, "$ENV{HOME}/.battrick") {
           19  +        mkdir "$ENV{HOME}/.battrick";
           20  +    }
           21  +
           22  +    my $schema = WWW:Battrick::Schema->connect(
           23  +        "dbi:SQLite:$ENV{HOME}/.battrick/data.db"
           24  +    );
           25  +
           26  +    eval {
           27  +        $schema->resultset('Player')->search->all;
           28  +    };
           29  +    $schema->deploy if $@;
           30  +
           31  +    return $schema;
           32  +}
           33  +
     4     34   
     5     35   sub run {
     6     36   }
     7     37   1;