Permalink
Browse files

integrated DBIC

  • Loading branch information...
dann committed May 3, 2009
1 parent e54abce commit 70fc0aaeb17a0bc71e6fa983d956f934e8762304
@@ -0,0 +1,6 @@
+CREATE TABLE user (
+ id INTEGER PRIMARY KEY,
+ name VARCHAR(255) NOT NULL
+);
+
+
@@ -0,0 +1,19 @@
+package [% module %]::Service::Base::DBIC;
+use Mouse;
+use [% module %]::Schema;
+use [% module %]::Cache;
+with 'Angelos::Service::Role::DBIC';
+
+has schema => (
+ +default => sub {
+ [% module %]::Schema->master;
+ }
+);
+
+has 'cache' => (
+ +default => sub {
+ [% module %]::Cache->instance;
+ }
+);
+
+1;
@@ -64,6 +64,8 @@ sub generate_schema {
$connect_info,
);
+ $self->overwrite_schema_file($app_class);
+
}
sub setup_database {
@@ -109,4 +111,27 @@ sub setup_context {
local *Angelos::Registrar::context = sub {$app};
}
+sub overwrite_schema_file {
+ my($self, $app_class) = @_;
+ $app_class =~ s/::/\//;
+ my $fh = file('lib', $app_class, 'Schema.pm')->openw or die "Schema file doesn't exist...";
+ my $schema_template = << "END";
+package ${app_class}::Schema;
+use strict;
+use warnings;
+use ${app_class}::Config;
+use base 'Angelos::ORM::DBIC::Schema';
+
+sub config {
+ ${app_class}::Config->instance;
+}
+
+__PACKAGE__->load_classes;
+1;
+END
+
+ print $fh $schema_template;
+ $fh->close;
+}
+
1;
@@ -424,7 +424,27 @@ template: |+
__END__
---
-dir: lib/____var-module_path-var____/Service/Base
+file: lib/____var-module_path-var____/Service/Base/DBIC.pm
+template: |
+ package [% module %]::Service::Base::DBIC;
+ use Mouse;
+ use [% module %]::Schema;
+ use [% module %]::Cache;
+ with 'Angelos::Service::Role::DBIC';
+
+ has schema => (
+ +default => sub {
+ [% module %]::Schema->master;
+ }
+ );
+
+ has 'cache' => (
+ +default => sub {
+ [% module %]::Cache->instance;
+ }
+ );
+
+ 1;
---
file: lib/____var-module_path-var____/CLI/Command/Echo.pm
template: |
@@ -753,8 +773,13 @@ template: |+
---
file: db/schema.sql
-is_binary: 1
-template: ''
+template: |+
+ CREATE TABLE user (
+ id INTEGER PRIMARY KEY,
+ name VARCHAR(255) NOT NULL
+ );
+
+
---
file: tools/test_it
template: |
@@ -198,7 +198,8 @@ sub count_literal {
sub _resultset {
my $self = shift;
- $self->schema->resultset( $self->resultset_moniker );
+ my $rs = $self->schema->resultset( $self->resultset_moniker );
+ $rs;
}
sub build_resultset_moniker {
File renamed without changes.

0 comments on commit 70fc0aa

Please sign in to comment.