DBIx-Class-Graph

 view release on metacpan or  search on metacpan

lib/DBIx/Class/Graph/Role/ResultSet.pm  view on Meta::CPAN

package DBIx::Class::Graph::Role::ResultSet;
{
  $DBIx::Class::Graph::Role::ResultSet::VERSION = '1.05';
}

use strict;
use warnings;
use Moose::Role;
use DBIx::Class::Graph::Wrapper;

use Scalar::Util qw(weaken);

has _graph => (
    is         => 'rw',
    isa        => 'DBIx::Class::Graph::Wrapper',
    lazy_build => 1,
    handles    => \&_import_methods
);
has _graph_rel => ( is => 'rw' );

sub _import_methods {

lib/DBIx/Class/Graph/Role/ResultSet.pm  view on Meta::CPAN

    my $source = $self->result_class;
    my ($pkey) = $source->primary_columns;
    my $rel    = $source->_graph_rel;
    my @obj    = $self->search( undef, { prefetch => $rel } )->all;
    $self->set_cache( \@obj );
    my $g = DBIx::Class::Graph::Wrapper->new( refvertexed => 1 );

    for (@obj) {
        $g->add_vertex($_);
        $_->_graph($g);
        weaken( $_->{_graph} );

    }

    $g->[99] = 1;
    foreach my $row (@obj) {
        my ( $from, $to ) = ();
        my $col = $source->_graph_column;
        if ( $row->result_source->has_column($col) ) {
            next
                unless ( my $pre



( run in 0.322 second using v1.01-cache-2.11-cpan-65fba6d93b7 )