1 package DBIx::Class::ResultSourceProxy::Table;
6 use base qw/DBIx::Class::ResultSourceProxy/;
8 use DBIx::Class::ResultSource::Table;
10 __PACKAGE__->mk_classdata(table_class => 'DBIx::Class::ResultSource::Table');
12 __PACKAGE__->mk_classdata('table_alias'); # FIXME: Doesn't actually do
15 sub _init_result_source_instance {
18 $class->mk_classdata('result_source_instance')
19 unless $class->can('result_source_instance');
21 my $table = $class->result_source_instance;
22 my $class_has_table_instance = ($table and $table->result_class eq $class);
23 return $table if $class_has_table_instance;
26 $table = $class->table_class->new({
28 result_class => $class,
34 $table = $class->table_class->new({
36 result_class => $class,
41 $class->result_source_instance($table);
48 DBIx::Class::ResultSourceProxy::Table - provides a classdata table
49 object and method proxies
53 __PACKAGE__->table('cd');
54 __PACKAGE__->add_columns(qw/cdid artist title year/);
55 __PACKAGE__->set_primary_key('cdid');
61 __PACKAGE__->add_columns(qw/cdid artist title year/);
63 Adds columns to the current class and creates accessors for them.
69 __PACKAGE__->table('tbl_name');
71 Gets or sets the table name.
76 my ($class, $table) = @_;
77 return $class->result_source_instance->name unless $table;
79 unless (Scalar::Util::blessed($table) && $table->isa($class->table_class)) {
80 $table = $class->table_class->new({
81 $class->can('result_source_instance') ?
82 %{$class->result_source_instance||{}} : (),
84 result_class => $class,
89 $class->mk_classdata('result_source_instance')
90 unless $class->can('result_source_instance');
92 $class->result_source_instance($table);
94 return $class->result_source_instance->name;
99 if ($obj->has_column($col)) { ... }
101 Returns 1 if the class has a column of this name, 0 otherwise.
107 my $info = $obj->column_info($col);
109 Returns the column metadata hashref for a column. For a description of
110 the various types of column data in this hashref, see
111 L<DBIx::Class::ResultSource/add_column>
117 my @column_names = $obj->columns;
125 Matt S. Trout <mst@shadowcatsystems.co.uk>
129 You may distribute this code under the same terms as Perl itself.