/[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 1150 - (hide annotations)
Wed Jul 1 18:41:28 2009 UTC (14 years, 10 months ago) by dpavlin
File size: 1199 byte(s)
mis-named room_markup renamed to room_as_makrup
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     our $dbh;
13     sub dbh {
14     my ($self) = @_;
15    
16     return $dbh if defined $dbh;
17    
18     $dbh = DBI->connect( $self->dsn, '', '', { RaiseError => 1 } ) || die $DBI::errstr;
19     $dbh->do( qq{ set client_encoding='utf-8' } ) if $self->dsn =~ m{pg}i;
20    
21     return $dbh;
22     }
23    
24 dpavlin 1086 sub as_markup {
25     my ($self) = @_;
26    
27 dpavlin 1147
28     my $url = $self->url_for( 'Reservation/create_as_markup' );
29    
30     return
31 dpavlin 1150 App::RoomReservation::Room->new->room_as_markup
32 dpavlin 1147 . qq|<a target="App::RoomReservation::Reservation" href="$url">seat reservation</a>|
33     ;
34 dpavlin 1086 }
35    
36 dpavlin 1147 # my $url = $self->uri_for( 'Reservation/create_as_makrup' );
37    
38     sub url_for {
39     my ( $self, $to ) = @_;
40     my $app = ref($self);
41     $app =~ s{^(App::[^:]+)::.+$}{$1};
42     $app .= '::' . $to;
43    
44     my ( $class, $method ) = split(m{/}, $app);
45     $method =~ s{\?.+$}{}; # remove arguments
46     Class::MOP::load_class( $class );
47     die "$class doesn't implement $method" unless $class->meta->has_method($method);
48    
49 dpavlin 1148 return
50     $self->request_url->scheme . '://' . $self->request_url->authority . '/' . $app;
51 dpavlin 1147 }
52    
53 dpavlin 1133 __PACKAGE__->meta->make_immutable;
54     no Moose;
55    
56 dpavlin 1086 1;

  ViewVC Help
Powered by ViewVC 1.1.26