Catalyst-Model-KiokuDB

 view release on metacpan or  search on metacpan

lib/Catalyst/Model/KiokuDB.pm  view on Meta::CPAN

package Catalyst::Model::KiokuDB;
use Moose;

use KiokuX::Model;
use Scope::Guard;
use Scalar::Util qw(weaken);
use overload ();
use Hash::Util::FieldHash::Compat qw(fieldhash);
use Carp;

sub format_table;

use namespace::clean -except => 'meta';

our $VERSION = "0.12";

extends qw(Catalyst::Model);

fieldhash my %scopes;

sub ACCEPT_CONTEXT {
    my ($self, $c, @args) = @_;

    $self->save_scope($c) if $self->manage_scope;

    return $self->model;
}

has manage_scope => (
    isa => "Bool",
    is  => "ro",
    default => 1,
);

has clear_leaks => (
    isa => "Bool",
    is  => "ro",
    default => 1,
);

has report_leaks => (
    isa => "Bool",
    is  => "ro",
    default => 1,
);

has report_loads => (
    isa => "Bool",
    is  => "ro",
    default => 1,
);

sub scope_guard_needed {
    my $self = shift;

    $self->clear_leaks || $self->report_leaks || $self->report_loads;
}

has model => (
    isa => "KiokuX::Model",
    is  => "ro",
    predicate => "has_model",
    writer => "_model",
    handles => "KiokuDB::Role::API",
);



( run in 2.696 seconds using v1.01-cache-2.11-cpan-75ffa21a3d4 )