/[Frey]/trunk/lib/App/RoomReservation.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/lib/App/RoomReservation.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1154 - (hide annotations)
Wed Jul 1 22:39:51 2009 UTC (14 years, 10 months ago) by dpavlin
File size: 1267 byte(s)
hint about deployment
1 dpavlin 1086 package App::RoomReservation;
2     use Moose;
3    
4     extends 'Frey';
5     with 'Frey::Web';
6    
7 dpavlin 1098 use lib 'lib';
8 dpavlin 1095 use App::RoomReservation::Room;
9 dpavlin 1086
10 dpavlin 1098 sub dsn { 'DBI:Pg:dbname=room-reservation' }
11    
12 dpavlin 1154 =head1 DEPLOY
13    
14     $ createdb --encoding=utf-8 room-reservation
15    
16     =cut
17    
18 dpavlin 1098 our $dbh;
19     sub dbh {
20     my ($self) = @_;
21    
22     return $dbh if defined $dbh;
23    
24     $dbh = DBI->connect( $self->dsn, '', '', { RaiseError => 1 } ) || die $DBI::errstr;
25     $dbh->do( qq{ set client_encoding='utf-8' } ) if $self->dsn =~ m{pg}i;
26    
27     return $dbh;
28     }
29    
30 dpavlin 1086 sub as_markup {
31     my ($self) = @_;
32    
33 dpavlin 1147
34     my $url = $self->url_for( 'Reservation/create_as_markup' );
35    
36     return
37 dpavlin 1150 App::RoomReservation::Room->new->room_as_markup
38 dpavlin 1147 . qq|<a target="App::RoomReservation::Reservation" href="$url">seat reservation</a>|
39     ;
40 dpavlin 1086 }
41    
42 dpavlin 1147 # my $url = $self->uri_for( 'Reservation/create_as_makrup' );
43    
44     sub url_for {
45     my ( $self, $to ) = @_;
46     my $app = ref($self);
47     $app =~ s{^(App::[^:]+)::.+$}{$1};
48     $app .= '::' . $to;
49    
50     my ( $class, $method ) = split(m{/}, $app);
51     $method =~ s{\?.+$}{}; # remove arguments
52     Class::MOP::load_class( $class );
53     die "$class doesn't implement $method" unless $class->meta->has_method($method);
54    
55 dpavlin 1148 return
56     $self->request_url->scheme . '://' . $self->request_url->authority . '/' . $app;
57 dpavlin 1147 }
58    
59 dpavlin 1133 __PACKAGE__->meta->make_immutable;
60     no Moose;
61    
62 dpavlin 1086 1;

  ViewVC Help
Powered by ViewVC 1.1.26