Skip to content

Instantly share code, notes, and snippets.

@domm
Created July 1, 2010 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save domm/460542 to your computer and use it in GitHub Desktop.
Save domm/460542 to your computer and use it in GitHub Desktop.
sub kiokudb_handle {
my $self = shift;
croak "Can't call kiokudb_handle on unconnected schema" unless ref $self;
unless ( $self->{kiokudb_handle} ) {
require KiokuDB;
require KiokuDB::Backend::DBI;
my $dir = KiokuDB->new(
backend => my $backend = KiokuDB::Backend::DBI->new(
connected_schema => $self,
),
);
$backend->meta->get_attribute('schema')->_weaken_value($backend); # FIXME proper MOP api?
# not weak
$self->{kiokudb_handle} = $dir;
unless ( $self->kiokudb_entries_source_name ) {
$self->define_kiokudb_schema( extra_entries_columns => $backend->columns );
}
}
$self->{kiokudb_handle};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment