1 package DBIx::Class::ResultSourceProxy::Table;
6 use base qw/DBIx::Class::ResultSourceProxy/;
8 use DBIx::Class::ResultSource::Table;
9 use Scalar::Util 'blessed';
12 __PACKAGE__->mk_classdata(table_class => 'DBIx::Class::ResultSource::Table');
14 __PACKAGE__->mk_classdata('table_alias'); # FIXME: Doesn't actually do
17 sub _init_result_source_instance {
20 $class->mk_classdata('result_source_instance')
21 unless $class->can('result_source_instance');
23 my $table = $class->result_source_instance;
24 my $class_has_table_instance = ($table and $table->result_class eq $class);
25 return $table if $class_has_table_instance;
27 my $table_class = $class->table_class;
28 $class->ensure_class_loaded($table_class);
31 $table = $table_class->new({
33 result_class => $class,
39 $table = $table_class->new({
41 result_class => $class,
46 $class->result_source_instance($table);
53 DBIx::Class::ResultSourceProxy::Table - provides a classdata table
54 object and method proxies
58 __PACKAGE__->table('cd');
59 __PACKAGE__->add_columns(qw/cdid artist title year/);
60 __PACKAGE__->set_primary_key('cdid');
66 __PACKAGE__->add_columns(qw/cdid artist title year/);
68 Adds columns to the current class and creates accessors for them.
74 __PACKAGE__->table('tbl_name');
76 Gets or sets the table name.
81 my ($class, $table) = @_;
82 return $class->result_source_instance->name unless $table;
84 unless (blessed $table && $table->isa($class->table_class)) {
86 my $table_class = $class->table_class;
87 $class->ensure_class_loaded($table_class);
89 $table = $table_class->new({
90 $class->can('result_source_instance') ?
91 %{$class->result_source_instance||{}} : (),
93 result_class => $class,
98 $class->mk_classdata('result_source_instance')
99 unless $class->can('result_source_instance');
101 $class->result_source_instance($table);
103 return $class->result_source_instance->name;
108 if ($obj->has_column($col)) { ... }
110 Returns 1 if the class has a column of this name, 0 otherwise.
116 my $info = $obj->column_info($col);
118 Returns the column metadata hashref for a column. For a description of
119 the various types of column data in this hashref, see
120 L<DBIx::Class::ResultSource/add_column>
126 my @column_names = $obj->columns;
134 Matt S. Trout <mst@shadowcatsystems.co.uk>
138 You may distribute this code under the same terms as Perl itself.