From: Matt S Trout Date: Fri, 20 Jan 2006 03:06:56 +0000 (+0000) Subject: Added register_column API X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1f23a8774ca0b1a210e4c94f4a0d494bd5bc1f07;p=dbsrgits%2FDBIx-Class-Historic.git Added register_column API --- diff --git a/lib/DBIx/Class/CDBICompat/ColumnCase.pm b/lib/DBIx/Class/CDBICompat/ColumnCase.pm index f0c3453..7cd324f 100644 --- a/lib/DBIx/Class/CDBICompat/ColumnCase.pm +++ b/lib/DBIx/Class/CDBICompat/ColumnCase.pm @@ -10,15 +10,10 @@ sub _register_column_group { return $class->next::method($group => map lc, @cols); } -sub _register_columns { - my ($class, @cols) = @_; - return $class->next::method(map lc, @cols); -} - sub add_columns { my ($class, @cols) = @_; + $class->mk_group_accessors(column => @cols); $class->result_source_instance->add_columns(map lc, @cols); - $class->_mk_column_accessors(@cols); } sub has_a { diff --git a/lib/DBIx/Class/ResultSourceInstance.pm b/lib/DBIx/Class/ResultSourceInstance.pm index 45a57d0..3b1a92e 100644 --- a/lib/DBIx/Class/ResultSourceInstance.pm +++ b/lib/DBIx/Class/ResultSourceInstance.pm @@ -10,8 +10,11 @@ sub resultset_class { shift->result_source_instance->resultset_class(@_) } sub add_columns { my ($class, @cols) = @_; - $class->result_source_instance->add_columns(@cols); - $class->_mk_column_accessors(@cols); + my $source = $class->result_source_instance; + $source->add_columns(@cols); + foreach my $c (grep { !ref } @cols) { + $class->register_column($c => $source->column_info($c)); + } } sub _select_columns { diff --git a/lib/DBIx/Class/Row.pm b/lib/DBIx/Class/Row.pm index f034863..21003db 100644 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@ -320,8 +320,17 @@ sub is_changed { Accessor to the ResultSource this object was created from +=head2 register_column + + Registers a column on the class and creates an accessor for it + =cut +sub register_column { + my ($class, $col, $info) = @_; + $class->mk_group_accessors('column' => $col); +} + 1; =head1 AUTHORS diff --git a/lib/DBIx/Class/TableInstance.pm b/lib/DBIx/Class/TableInstance.pm index 13b100a..5a7603a 100644 --- a/lib/DBIx/Class/TableInstance.pm +++ b/lib/DBIx/Class/TableInstance.pm @@ -22,13 +22,6 @@ DBIx::Class::TableInstance - provides a classdata table object and method proxie =head1 METHODS -=cut - -sub _mk_column_accessors { - my ($class, @cols) = @_; - $class->mk_group_accessors('column' => grep { !ref } @cols); -} - =head2 add_columns __PACKAGE__->add_columns(qw/col1 col2 col3/);