1 package DBIx::Class::ResultSourceProxy::Table;
6 use base qw/DBIx::Class::ResultSourceProxy/;
8 use DBIx::Class::ResultSource::Table;
11 __PACKAGE__->mk_classdata(table_class => 'DBIx::Class::ResultSource::Table');
13 __PACKAGE__->mk_classdata('table_alias'); # FIXME: Doesn't actually do
16 sub _init_result_source_instance {
19 $class->mk_classdata('result_source_instance')
20 unless $class->can('result_source_instance');
22 my $table = $class->result_source_instance;
23 my $class_has_table_instance = ($table and $table->result_class eq $class);
24 return $table if $class_has_table_instance;
27 $table = $class->table_class->new({
29 result_class => $class,
35 $table = $class->table_class->new({
37 result_class => $class,
42 $class->result_source_instance($table);
49 DBIx::Class::ResultSourceProxy::Table - provides a classdata table
50 object and method proxies
54 __PACKAGE__->table('cd');
55 __PACKAGE__->add_columns(qw/cdid artist title year/);
56 __PACKAGE__->set_primary_key('cdid');
62 __PACKAGE__->add_columns(qw/cdid artist title year/);
64 Adds columns to the current class and creates accessors for them.
70 __PACKAGE__->table('tbl_name');
72 Gets or sets the table name.
77 my ($class, $table) = @_;
78 return $class->result_source_instance->name unless $table;
80 unless (Scalar::Util::blessed($table) && $table->isa($class->table_class)) {
81 $table = $class->table_class->new({
82 $class->can('result_source_instance') ?
83 %{$class->result_source_instance||{}} : (),
85 result_class => $class,
90 $class->mk_classdata('result_source_instance')
91 unless $class->can('result_source_instance');
93 $class->result_source_instance($table);
95 return $class->result_source_instance->name;
100 if ($obj->has_column($col)) { ... }
102 Returns 1 if the class has a column of this name, 0 otherwise.
108 my $info = $obj->column_info($col);
110 Returns the column metadata hashref for a column. For a description of
111 the various types of column data in this hashref, see
112 L<DBIx::Class::ResultSource/add_column>
118 my @column_names = $obj->columns;
126 Matt S. Trout <mst@shadowcatsystems.co.uk>
130 You may distribute this code under the same terms as Perl itself.