| 1 | package Mojolicious::Plugin::RoutesAuthDBI::Model::Namespaces; | ||
| 2 | #~ use Mojo::Base 'DBIx::Mojo::Model'; | ||
| 3 | use Mojo::Base 'Mojolicious::Plugin::RoutesAuthDBI::Model::Base'; | ||
| 4 | |||
| 5 | #~ sub new { | ||
| 6 | #~ state $self = shift->SUPER::new(@_); | ||
| 7 | #~ } | ||
| 8 | |||
| 9 | sub app_ns { | ||
| 10 | my $self = ref($_[0]) ? shift : shift->new; | ||
| 11 | |||
| 12 | $self->dbh->selectall_arrayref($self->sth('namespaces', where=>"where app_ns=1::bit(1)", order=>"order by ts - (coalesce(interval_ts, 0::int)::varchar || ' second')::interval"), { Slice => {namespace=>1} },); | ||
| 13 | } | ||
| 14 | |||
| 15 | sub access { | ||
| 16 | my $self = ref($_[0]) ? shift : shift->new; | ||
| 17 | |||
| 18 | $self->dbh->selectrow_array($self->sth('access namespace'), undef, (shift, shift)); | ||
| 19 | } | ||
| 20 | |||
| 21 | sub namespace { | ||
| 22 | my $self = ref($_[0]) ? shift : shift->new; | ||
| 23 | |||
| 24 | $self->dbh->selectrow_hashref($self->sth('namespace'), undef, (@_)); | ||
| 25 | } | ||
| 26 | |||
| 27 | sub new_namespace { | ||
| 28 | my $self = ref($_[0]) ? shift : shift->new; | ||
| 29 | |||
| 30 | $self->dbh->selectrow_hashref($self->sth('new namespace'), undef, (@_)); | ||
| 31 | } | ||
| 32 | |||
| 33 | sub namespaces { | ||
| 34 | my $self = ref($_[0]) ? shift : shift->new; | ||
| 35 | $self->dbh->selectall_arrayref($self->sth('namespaces'), { Slice => {} }, ); | ||
| 36 | } | ||
| 37 | |||
| 38 | |||
| 39 | 1; | ||
| 40 | |||
| 41 | __DATA__ |