1 package DBIx::Class::ResultSourceProxy::Table;
6 use base qw/DBIx::Class::ResultSourceProxy/;
8 __PACKAGE__->mk_classdata(table_class => 'DBIx::Class::ResultSource::Table');
10 __PACKAGE__->mk_classdata('table_alias'); # FIXME: Doesn't actually do
13 sub _init_result_source_instance {
16 $class->mk_classdata('result_source_instance')
17 unless $class->can('result_source_instance');
19 my $table = $class->result_source_instance;
20 my $class_has_table_instance = ($table and $table->result_class eq $class);
21 return $table if $class_has_table_instance;
23 my $table_class = $class->table_class;
24 $class->ensure_class_loaded($table_class);
27 $table = $table_class->new({
29 result_class => $class,
35 $table = $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;
81 my $table_class = $class->table_class;
82 $class->ensure_class_loaded($table_class);
84 $table = $table_class->new({
85 $class->can('result_source_instance') ?
86 %{$class->result_source_instance||{}} : (),
88 result_class => $class,
93 $class->mk_classdata('result_source_instance')
94 unless $class->can('result_source_instance');
96 $class->result_source_instance($table);
98 return $class->result_source_instance->name;
103 if ($obj->has_column($col)) { ... }
105 Returns 1 if the class has a column of this name, 0 otherwise.
111 my $info = $obj->column_info($col);
113 Returns the column metadata hashref for a column. For a description of
114 the various types of column data in this hashref, see
115 L<DBIx::Class::ResultSource/add_column>
121 my @column_names = $obj->columns;
129 Matt S. Trout <mst@shadowcatsystems.co.uk>
133 You may distribute this code under the same terms as Perl itself.