From: Aran Deltac Date: Fri, 24 Mar 2006 15:16:41 +0000 (+0000) Subject: Rename Positioned as Positional. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1e3ff0144580732bc73b4f8041ace7da5eae488c;p=dbsrgits%2FDBIx-Class-Historic.git Rename Positioned as Positional. --- diff --git a/lib/DBIx/Class/Manual/Component.pod b/lib/DBIx/Class/Manual/Component.pod index e7c8a60..1107639 100644 --- a/lib/DBIx/Class/Manual/Component.pod +++ b/lib/DBIx/Class/Manual/Component.pod @@ -68,6 +68,12 @@ L - Hooks for Storable freeze/thaw. L - Validate all data before submitting to your database. +L - Modify the position of objects in an ordered list. + +L - Manage a tree of data using the common adjacency list model. + +L - Manage a positional tree of data using the nested set model. + =head2 Core These are the components that all, or nearly all, people will use diff --git a/lib/DBIx/Class/Positioned.pm b/lib/DBIx/Class/Positional.pm similarity index 97% rename from lib/DBIx/Class/Positioned.pm rename to lib/DBIx/Class/Positional.pm index 5266f9d..da1fb0a 100644 --- a/lib/DBIx/Class/Positioned.pm +++ b/lib/DBIx/Class/Positional.pm @@ -1,12 +1,12 @@ # vim: ts=8:sw=4:sts=4:et -package DBIx::Class::Positioned; +package DBIx::Class::Positional; use strict; use warnings; use base qw( DBIx::Class ); =head1 NAME -DBIx::Class::Positioned - Modify the position of objects in an ordered list. +DBIx::Class::Positional - Modify the position of objects in an ordered list. =head1 SYNOPSIS @@ -19,10 +19,10 @@ Create a table for your positionable data. ); # Optional: group_id INTEGER NOT NULL -In your Schema or DB class add Positioned to the top +In your Schema or DB class add Positional to the top of the component list. - __PACKAGE__->load_components(qw( Positioned ... )); + __PACKAGE__->load_components(qw( Positional ... )); Specify the column that stores the position number for each row. @@ -85,7 +85,7 @@ __PACKAGE__->mk_classdata( 'position_column' => 'position' ); This method specified a column to limit all queries in this module by. This effectively allows you to have multiple -positioned lists within the same table. +positional lists within the same table. =cut diff --git a/lib/DBIx/Class/Tree/AdjacencyList.pm b/lib/DBIx/Class/Tree/AdjacencyList.pm index c0175d6..57d3958 100644 --- a/lib/DBIx/Class/Tree/AdjacencyList.pm +++ b/lib/DBIx/Class/Tree/AdjacencyList.pm @@ -24,7 +24,7 @@ of the component list. __PACKAGE__->load_components(qw( Tree::AdjacencyList ... )); # If you want positionable data make sure this # module comes first, as in: - __PACKAGE__->load_components(qw( Tree::AdjacencyList Positioned ... )); + __PACKAGE__->load_components(qw( Tree::AdjacencyList Positional ... )); Specify the column that contains the parent ID each row. @@ -63,8 +63,8 @@ other rows. Declares the name of the column that contains the self-referential ID which defines the parent row. Defaults to "parent_id". -If you are useing the Positioned component then this parent_column -will automatically be used as the collection_column. +If you are useing the L component then this +parent_column will automatically be used as the collection_column. =cut @@ -81,7 +81,7 @@ parent ID. If setting the parent ID then 0 will be returned if the object already has the specified parent, and 1 on success. -If you are using the Positioned component this +If you are using the L component this module will first move the object to the last position of the list, change the parent ID, then move the object to the last position of the new list. This ensures the intergrity @@ -97,10 +97,10 @@ sub parent { $new_parent = $new_parent->id() || 0; } return 0 if ($new_parent == ($self->get_column($parent_column)||0)); - my $is_positioned = $self->isa('DBIx::Class::Positioned'); - $self->move_last() if ($is_positioned); + my $is_positional = $self->isa('DBIx::Class::Positional'); + $self->move_last() if ($is_positional); $self->set_column( $parent_column => $new_parent ); - if ($is_positioned) { + if ($is_positional) { $self->set_column( $self->position_column() => $self->search( {$self->_collection_clause()} )->count() + 1 ); @@ -121,7 +121,7 @@ sub parent { Returns a list or record set, depending on context, of all the objects one level below the current one. -If you are using the Positioned component then this method +If you are using the L component then this method will return the children sorted by the position column. =cut @@ -144,10 +144,10 @@ need to use them. =head2 _collection_clause This method is provided as an override of the method in -DBIx::Class::Positioned. This way Positioned and Tree::AdjacencyList +L. This way Positional and Tree::AdjacencyList may be used together without conflict. Make sure that in your component list that you load Tree::AdjacencyList before you -load Positioned. +load Positional. =cut diff --git a/t/helperrels/26positioned.t b/t/helperrels/26positional.t similarity index 76% rename from t/helperrels/26positioned.t rename to t/helperrels/26positional.t index 8e42bbd..d4cc2e7 100644 --- a/t/helperrels/26positioned.t +++ b/t/helperrels/26positional.t @@ -3,5 +3,5 @@ use lib qw(t/lib); use DBICTest; use DBICTest::HelperRels; -require "t/run/26positioned.tl"; +require "t/run/26positional.tl"; run_tests(DBICTest->schema); diff --git a/t/lib/DBICTest/Schema.pm b/t/lib/DBICTest/Schema.pm index e43c898..90308ab 100644 --- a/t/lib/DBICTest/Schema.pm +++ b/t/lib/DBICTest/Schema.pm @@ -7,7 +7,7 @@ no warnings qw/qw/; __PACKAGE__->load_classes(qw/ Artist - Employee::Positioned + Employee::Positional Employee::AdjacencyList CD #dummy diff --git a/t/lib/DBICTest/Schema/Employee/AdjacencyList.pm b/t/lib/DBICTest/Schema/Employee/AdjacencyList.pm index 5af4532..50f7abd 100644 --- a/t/lib/DBICTest/Schema/Employee/AdjacencyList.pm +++ b/t/lib/DBICTest/Schema/Employee/AdjacencyList.pm @@ -5,7 +5,7 @@ use base 'DBIx::Class'; __PACKAGE__->load_components(qw( Tree::AdjacencyList - Positioned + Positional PK::Auto Core )); diff --git a/t/lib/DBICTest/Schema/Employee/Positioned.pm b/t/lib/DBICTest/Schema/Employee/Positional.pm similarity index 82% rename from t/lib/DBICTest/Schema/Employee/Positioned.pm rename to t/lib/DBICTest/Schema/Employee/Positional.pm index 3ce5744..6234132 100644 --- a/t/lib/DBICTest/Schema/Employee/Positioned.pm +++ b/t/lib/DBICTest/Schema/Employee/Positional.pm @@ -1,11 +1,11 @@ package # hide from PAUSE - DBICTest::Schema::Employee::Positioned; + DBICTest::Schema::Employee::Positional; use base 'DBIx::Class'; -__PACKAGE__->load_components(qw( Positioned PK::Auto Core )); +__PACKAGE__->load_components(qw( Positional PK::Auto Core )); -__PACKAGE__->table('employees_positioned'); +__PACKAGE__->table('employees_positional'); __PACKAGE__->add_columns( employee_id => { diff --git a/t/lib/sqlite.sql b/t/lib/sqlite.sql index 1e8f83e..81d56ae 100644 --- a/t/lib/sqlite.sql +++ b/t/lib/sqlite.sql @@ -1,6 +1,6 @@ -- -- Created by SQL::Translator::Producer::SQLite --- Created on Thu Mar 23 19:41:26 2006 +-- Created on Fri Mar 24 07:13:26 2006 -- BEGIN TRANSACTION; @@ -13,16 +13,6 @@ CREATE TABLE serialized ( ); -- --- Table: employees_positioned --- -CREATE TABLE employees_positioned ( - employee_id INTEGER PRIMARY KEY NOT NULL, - position integer NOT NULL, - group_id integer, - name varchar(100) -); - --- -- Table: employees_adjacencylist -- CREATE TABLE employees_adjacencylist ( @@ -122,6 +112,16 @@ CREATE TABLE twokeys ( ); -- +-- Table: employees_positional +-- +CREATE TABLE employees_positional ( + employee_id INTEGER PRIMARY KEY NOT NULL, + position integer NOT NULL, + group_id integer, + name varchar(100) +); + +-- -- Table: fourkeys -- CREATE TABLE fourkeys ( diff --git a/t/run/26positioned.tl b/t/run/26positional.tl similarity index 95% rename from t/run/26positioned.tl rename to t/run/26positional.tl index 224e658..6d179b7 100644 --- a/t/run/26positioned.tl +++ b/t/run/26positional.tl @@ -5,7 +5,7 @@ sub run_tests { plan tests => 321; my $schema = shift; - my $employees = $schema->resultset('Employee::Positioned'); + my $employees = $schema->resultset('Employee::Positional'); $employees->delete(); foreach (1..5) { @@ -16,7 +16,7 @@ sub run_tests { hammer_rs( $employees ); - DBICTest::Employee::Positioned->collection_column('group_id'); + DBICTest::Employee::Positional->collection_column('group_id'); $employees->delete(); foreach my $group_id (1..3) { foreach (1..6) {