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;
26 my $table_class = $class->table_class;
27 $class->ensure_class_loaded($table_class);
30 $table = $table_class->new({
32 result_class => $class,
38 $table = $table_class->new({
40 result_class => $class,
45 $class->result_source_instance($table);
52 DBIx::Class::ResultSourceProxy::Table - provides a classdata table
53 object and method proxies
57 __PACKAGE__->table('cd');
58 __PACKAGE__->add_columns(qw/cdid artist title year/);
59 __PACKAGE__->set_primary_key('cdid');
65 __PACKAGE__->add_columns(qw/cdid artist title year/);
67 Adds columns to the current class and creates accessors for them.
73 __PACKAGE__->table('tbl_name');
75 Gets or sets the table name.
80 my ($class, $table) = @_;
81 return $class->result_source_instance->name unless $table;
83 unless (Scalar::Util::blessed($table) && $table->isa($class->table_class)) {
85 my $table_class = $class->table_class;
86 $class->ensure_class_loaded($table_class);
88 $table = $table_class->new({
89 $class->can('result_source_instance') ?
90 %{$class->result_source_instance||{}} : (),
92 result_class => $class,
97 $class->mk_classdata('result_source_instance')
98 unless $class->can('result_source_instance');
100 $class->result_source_instance($table);
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.