use warnings
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Schema / Graph / Edge.pm
1 package SQL::Translator::Schema::Graph::Edge;
2
3 use strict;
4 use warnings;
5
6 use Class::MakeMethods::Template::Hash (
7   new => ['new'],
8   scalar => [ qw( type ) ],
9   array => [ qw( traversals ) ],
10   object => [
11           'thisfield'    => {class => 'SQL::Translator::Schema::Field'}, #FIXME
12           'thatfield'    => {class => 'SQL::Translator::Schema::Field'}, #FIXME
13           'thisnode'     => {class => 'SQL::Translator::Schema::Graph::Node'},
14           'thatnode'     => {class => 'SQL::Translator::Schema::Graph::Node'},
15
16          ],
17 );
18
19 sub flip {
20   my $self = shift;
21
22 #warn "self thisfield: ".$self->thisfield->name;
23 #warn "self thatfield: ".$self->thatfield->name;
24
25   return SQL::Translator::Schema::Graph::Edge->new( thisfield => $self->thatfield,
26                                        thatfield => $self->thisfield,
27                                        thisnode  => $self->thatnode,
28                                        thatnode  => $self->thisnode,
29                                        type => $self->type eq 'import' ? 'export' : 'import'
30                                       );
31 }
32
33 1;