1 package DBIx::Class::TableInstance;
6 use base qw/DBIx::Class::ResultSourceInstance/;
7 use DBIx::Class::Table;
9 __PACKAGE__->mk_classdata('table_alias'); # FIXME: Doesn't actually do anything yet!
11 __PACKAGE__->mk_classdata('table_class' => 'DBIx::Class::Table');
15 DBIx::Class::TableInstance - provides a classdata table object and method proxies
19 __PACKAGE__->table('foo');
20 __PACKAGE__->add_columns(qw/id bar baz/);
21 __PACKAGE__->set_primary_key('id');
27 sub _mk_column_accessors {
28 my ($class, @cols) = @_;
29 $class->mk_group_accessors('column' => grep { !ref } @cols);
34 __PACKAGE__->add_columns(qw/col1 col2 col3/);
36 Adds columns to the current class and creates accessors for them.
42 __PACKAGE__->table('tbl_name');
44 Gets or sets the table name.
49 my ($class, $table) = @_;
50 return $class->result_source_instance->name unless $table;
52 $table = $class->table_class->new(
55 result_class => $class,
57 if ($class->can('result_source_instance')) {
58 $table->{_columns} = { %{$class->result_source_instance->{_columns}||{}} };
59 $table->{_ordered_columns} =
60 [ @{$class->result_source_instance->{_ordered_columns}||[]} ];
63 $class->mk_classdata('result_source_instance' => $table);
64 if ($class->can('schema_instance')) {
65 $class =~ m/([^:]+)$/;
66 $class->schema_instance->register_class($class, $class);
72 if ($obj->has_column($col)) { ... }
74 Returns 1 if the class has a column of this name, 0 otherwise.
80 my $info = $obj->column_info($col);
82 Returns the column metadata hashref for a column.
88 my @column_names = $obj->columns;
96 Matt S. Trout <mst@shadowcatsystems.co.uk>
100 You may distribute this code under the same terms as Perl itself.