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);
43 if ($class->can('schema_instance')) {
44 $class =~ m/([^:]+)$/;
45 $class->schema_instance->register_class($class, $class);
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 $table = $class->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 if ($class->can('schema_instance')) {
99 $class =~ m/([^:]+)$/;
100 $class->schema_instance->register_class($class, $class);
102 return $class->result_source_instance->name;
107 if ($obj->has_column($col)) { ... }
109 Returns 1 if the class has a column of this name, 0 otherwise.
115 my $info = $obj->column_info($col);
117 Returns the column metadata hashref for a column. For a description of
118 the various types of column data in this hashref, see
119 L<DBIx::Class::ResultSource/add_column>
125 my @column_names = $obj->columns;
133 Matt S. Trout <mst@shadowcatsystems.co.uk>
137 You may distribute this code under the same terms as Perl itself.