1 package DBIx::Class::ResultSourceProxy::Table;
6 use base qw/DBIx::Class::ResultSourceProxy/;
8 use DBIx::Class::ResultSource::Table;
9 use Scalar::Util 'blessed';
12 __PACKAGE__->mk_classdata(table_class => 'DBIx::Class::ResultSource::Table');
14 __PACKAGE__->mk_classdata('table_alias'); # FIXME: Doesn't actually do
17 sub _init_result_source_instance {
20 $class->mk_classdata('result_source_instance')
21 unless $class->can('result_source_instance');
23 my $table = $class->result_source_instance;
24 my $class_has_table_instance = ($table and $table->result_class eq $class);
25 return $table if $class_has_table_instance;
27 my $table_class = $class->table_class;
28 $class->ensure_class_loaded($table_class);
31 $table = $table_class->new({
33 result_class => $class,
39 $table = $table_class->new({
41 result_class => $class,
46 $class->result_source_instance($table);
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 unless (blessed $table && $table->isa($class->table_class)) {
86 my $table_class = $class->table_class;
87 $class->ensure_class_loaded($table_class);
89 $table = $table_class->new({
90 $class->can('result_source_instance')
91 ? %{$class->result_source_instance||{}}
95 result_class => $class,
99 $class->mk_classdata('result_source_instance')
100 unless $class->can('result_source_instance');
102 $class->result_source_instance($table);
104 return $class->result_source_instance->name;
109 __PACKAGE__->table_class('DBIx::Class::ResultSource::Table');
111 Gets or sets the table class used for construction and validation.
115 if ($obj->has_column($col)) { ... }
117 Returns 1 if the class has a column of this name, 0 otherwise.
121 my $info = $obj->column_info($col);
123 Returns the column metadata hashref for a column. For a description of
124 the various types of column data in this hashref, see
125 L<DBIx::Class::ResultSource/add_column>
129 my @column_names = $obj->columns;
131 =head1 FURTHER QUESTIONS?
133 Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>.
135 =head1 COPYRIGHT AND LICENSE
137 This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE>
138 by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can
139 redistribute it and/or modify it under the same terms as the
140 L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>.