Skip to content

Commit

Permalink
Adicionando rotina para facilitar encontrar o node root.
Browse files Browse the repository at this point in the history
Signed-off-by: Thiago Berlitz Rondon <thiago.rondon@gmail.com>
  • Loading branch information
thiagorondon committed May 17, 2011
1 parent 8c1db6e commit 6a982f2
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions lib/CMD/Data/Utils.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

package CMD::Data::Utils;

use strict;
use warnings;
use vars qw(@ISA @EXPORT_OK $VERSION @EXPORT_FAIL);
require Exporter;

@ISA = qw(Exporter);
@EXPORT_OK = qw(get_root_by_nodeid);

$VERSION = '0.01';
$VERSION = eval $VERSION;

sub get_root_by_nodeid {
my $node = shift;
my $root = $node;
my $point = $node;
while ($point) {
my @parent = $point->parents();
$root = $parent[0] if scalar @parent;
$point = $point->parent;
}
return $root;
}

1;

0 comments on commit 6a982f2

Please sign in to comment.