Padre
view release on metacpan or search on metacpan
lib/Padre/DB/Session.pm view on Meta::CPAN
package Padre::DB::Session;
# NOTE: This class is loaded automatically by Padre::DB, overlaying the
# code already auto-generated by Padre::DB. Do not load manually, as this
# module will not function standalone.
# NOTE: Portable Perl support is NOT required for this class, as it does
# not contain any file paths.
use 5.008;
use strict;
use warnings;
use Padre::Current ();
our $VERSION = '1.02';
my $PADRE_SESSION = 'padre-last';
sub last_padre_session {
my $class = shift;
my $transaction = Padre::Current->main->lock('DB');
# find last padre session
my ($padre) = Padre::DB::Session->select(
'where name = ?',
$PADRE_SESSION
);
# no such session, create one
unless ( defined $padre ) {
$padre = $class->create(
name => $PADRE_SESSION,
description => 'Last session within Padre',
last_update => time,
);
}
return $padre;
}
sub clear_last_session {
my $class = shift;
my $transaction = Padre::Current->main->lock('DB');
# Find last padre session (shortcut if none)
my ($padre) = Padre::DB::Session->select(
'where name = ?',
$PADRE_SESSION,
) or return;
# Remove any files in the session
Padre::DB::SessionFile->delete_where( 'session = ?', $padre->id );
# Remove the session itself
$padre->delete;
return;
}
sub files {
Padre::DB::SessionFile->select(
'where session = ?',
shift->id,
( run in 2.172 seconds using v1.01-cache-2.11-cpan-75ffa21a3d4 )