use Carp qw( croak );
__PACKAGE__->load_components(qw(
- Tree::AdjacencyList
Ordered
+ Tree::AdjacencyList
));
=head1 NAME
);
In your Schema or DB class add Tree::AdjacencyList::Ordered
-to the top of the component list.
+to the front of the component list.
__PACKAGE__->load_components(qw( Tree::AdjacencyList::Ordered ... ));
sub parent_column {
my $class = shift;
+ my $position_col = $class->position_column() || croak('You must call position_column() before calling parent_column()');
if (@_) {
- my $parent_col = shift;
- my $primary_col = ($class->primary_columns())[0];
- my $position_col = $class->position_column() || croak('You must call position_column() before calling parent_column()');
- $class->belongs_to( '_parent' => $class => { "foreign.$primary_col" => "self.$parent_col" } );
- $class->has_many( 'children' => $class => { "foreign.$parent_col" => "self.$primary_col" }, { order_by=>$position_col } );
- $class->_parent_column( $parent_col );
+ $class->grouping_column( @_ );
+ $class->next::method( @_ );
+ $class->relationship_info('children')->{attrs}->{order_by} = $position_col;
return 1;
}
- return $class->_parent_column();
+ return $class->grouping_column;
}
=head2 parent
$sibling->move_to( $self->get_column($self->position_column()) + 1 );
}
-=head1 PRIVATE METHODS
+1;
+__END__
-These methods are used internally. You should never have the
-need to use them.
+=head1 INHERITED METHODS
-=head2 grouping_column
+=head2 DBIx::Class::Ordered
-Postional's grouping_column method does not, and should not, be
-defined when using this module. This method just throws out an
-error if you try to use it.
+=over 4
-=cut
+=item *
-sub grouping_column {
- croak('Use parent_column() instead of grouping_column()');
-}
+L<siblings|DBIx::Class::Ordered/siblings>
-=head2 _grouping_clause
+=item *
-This method is provided as an override of the method in
-L<DBIx::Class::Ordered>. This method is what provides the
-glue between AdjacencyList and Ordered.
+L<first_sibling|DBIx::Class::Ordered/first_sibling>
-=cut
+=item *
-sub _grouping_clause {
- my( $self ) = @_;
- my $col = $self->_parent_column();
- return (
- $col => $self->get_column( $col )
- );
-}
+L<last_sibling|DBIx::Class::Ordered/last_sibling>
-1;
-__END__
+=item *
+
+L<previous_sibling|DBIx::Class::Ordered/previous_sibling>
+
+=item *
+
+L<next_sibling|DBIx::Class::Ordered/next_sibling>
+
+=item *
+
+L<move_previous|DBIx::Class::Ordered/move_previous>
+
+=item *
+
+L<move_next|DBIx::Class::Ordered/move_next>
+
+=item *
+
+L<move_first|DBIx::Class::Ordered/move_first>
+
+=item *
+
+L<move_last|DBIx::Class::Ordered/move_last>
+
+=item *
+
+L<move_to|DBIx::Class::Ordered/move_to>
+
+=item *
+
+L<insert|DBIx::Class::Ordered/insert>
+
+=item *
+
+L<delete|DBIx::Class::Ordered/delete>
+
+=back
+
+=head2 DBIx::Class::Tree::AdjacencyList
+
+=over 4
+
+=item *
+
+L<parent_column|DBIx::Class::Tree::AdjacencyList/parent_column>
+
+=item *
+
+L<parent|DBIx::Class::Tree::AdjacencyList/parent>
+
+=item *
+
+L<attach_child|DBIx::Class::Tree::AdjacencyList/attach_child>
+
+=item *
+
+L<siblings|DBIx::Class::Tree::AdjacencyList/siblings>
+
+=item *
+
+L<attach_sibling|DBIx::Class::Tree::AdjacencyList/attach_sibling>
+
+=back
+
+=head2 DBIx::Class
+
+=over 4
+
+=item *
+
+L<mk_classdata|DBIx::Class/mk_classdata>
+
+=item *
+
+L<component_base_class|DBIx::Class/component_base_class>
+
+=back
+
+=head2 DBIx::Class::Componentised
+
+=over 4
+
+=item *
+
+L<inject_base|DBIx::Class::Componentised/inject_base>
+
+=item *
+
+L<load_components|DBIx::Class::Componentised/load_components>
+
+=item *
+
+L<load_own_components|DBIx::Class::Componentised/load_own_components>
+
+=back
+
+=head2 Class::Data::Accessor
+
+=over 4
+
+=item *
+
+L<mk_classaccessor|Class::Data::Accessor/mk_classaccessor>
+
+=back
=head1 AUTHOR