From: David Kamholz Date: Tue, 7 Feb 2006 22:50:06 +0000 (+0000) Subject: add component_class accessors and use them for *_class X-Git-Tag: v0.05005~17 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fc9690056f17278f057021803b1124ebbd5a0d2d;p=dbsrgits%2FDBIx-Class.git add component_class accessors and use them for *_class --- diff --git a/lib/DBIx/Class/AccessorGroup.pm b/lib/DBIx/Class/AccessorGroup.pm index 79db519..4e42b27 100644 --- a/lib/DBIx/Class/AccessorGroup.pm +++ b/lib/DBIx/Class/AccessorGroup.pm @@ -142,6 +142,27 @@ sub set_simple { return $self->{$set} = $val; } +sub get_component_class { + my ($self, $get) = @_; + if (ref $self) { + return $self->{$get}; + } else { + $get = "_$get"; + return $self->can($get) ? $self->$get : undef; + } +} + +sub set_component_class { + my ($self, $set, $val) = @_; + eval "require $val"; + if (ref $self) { + return $self->{$set} = $val; + } else { + $set = "_$set"; + return $self->can($set) ? $self->$set($val) : $self->mk_classdata($set => $val); + } +} + 1; =head1 AUTHORS diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index 2d36f5e..eff072b 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -12,7 +12,8 @@ use base qw/DBIx::Class/; __PACKAGE__->load_components(qw/AccessorGroup/); __PACKAGE__->mk_group_accessors('simple' => - qw/_ordered_columns _columns _primaries _unique_constraints name resultset_class resultset_attributes result_class schema from _relationships/); + qw/_ordered_columns _columns _primaries _unique_constraints name resultset_attributes schema from _relationships/); +__PACKAGE__->mk_group_accessors('component_class' => qw/resultset_class result_class/); =head1 NAME diff --git a/lib/DBIx/Class/ResultSourceProxy/Table.pm b/lib/DBIx/Class/ResultSourceProxy/Table.pm index 4f23097..6717f82 100644 --- a/lib/DBIx/Class/ResultSourceProxy/Table.pm +++ b/lib/DBIx/Class/ResultSourceProxy/Table.pm @@ -4,11 +4,12 @@ use strict; use warnings; use base qw/DBIx::Class::ResultSourceProxy/; -use DBIx::Class::ResultSource::Table; +__PACKAGE__->load_components(qw/AccessorGroup/); -__PACKAGE__->mk_classdata('table_alias'); # FIXME: Doesn't actually do anything yet! +__PACKAGE__->mk_group_accessors('component_class' => 'table_class'); +__PACKAGE__->table_class('DBIx::Class::ResultSource::Table'); -__PACKAGE__->mk_classdata('table_class' => 'DBIx::Class::ResultSource::Table'); +__PACKAGE__->mk_classdata('table_alias'); # FIXME: Doesn't actually do anything yet! =head1 NAME