Begin Message model
This commit is contained in:
parent
eba062ebfa
commit
e1c07606b5
|
@ -29,9 +29,13 @@ helper test => sub {
|
||||||
state $test = GuestbookNg::Model::Test->new(pg => shift->pg)
|
state $test = GuestbookNg::Model::Test->new(pg => shift->pg)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
helper message => sub {
|
||||||
|
state $test = GuestbookNg::Model::Message->new(pg => shift->pg)
|
||||||
|
};
|
||||||
|
|
||||||
# Routes
|
# Routes
|
||||||
under sub ($c) {
|
under sub ($c) {
|
||||||
$c->test->create_table()
|
$c->pg->migrations->from_dir('migrations')->migrate(1);
|
||||||
};
|
};
|
||||||
|
|
||||||
get '/' => sub ($c) {
|
get '/' => sub ($c) {
|
||||||
|
|
13
lib/GuestbookNg/Model/Message.pm
Normal file
13
lib/GuestbookNg/Model/Message.pm
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
|
package GuestbookNg::Model::Message;
|
||||||
|
|
||||||
|
use Mojo::Base -base, -signatures;
|
||||||
|
|
||||||
|
has 'pg';
|
||||||
|
|
||||||
|
sub new($class, $pg, $object) {
|
||||||
|
bless {$pg => $object}
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
|
@ -14,10 +14,6 @@ sub test_model($self, $string) {
|
||||||
"you've supplied: $string"
|
"you've supplied: $string"
|
||||||
}
|
}
|
||||||
|
|
||||||
sub create_table($self) {
|
|
||||||
$self->pg->migrations->from_dir('migrations')->migrate(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub now($self) {
|
sub now($self) {
|
||||||
$self->pg->db->query('SELECT NOW() AS now')->text()
|
$self->pg->db->query('SELECT NOW() AS now')->text()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue