X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FResultSourceProxy%2FTable.pm;h=647a4089c60b940d9d01b027890e1c40796935d9;hb=a2bd379666d729133d65c85dc775627937084b18;hp=b39e0b646a5130d66f7d80b8a20baea1a44e3b27;hpb=35f61d278b515761c2dc3ac94059724a74e29793;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/ResultSourceProxy/Table.pm b/lib/DBIx/Class/ResultSourceProxy/Table.pm index b39e0b6..647a408 100644 --- a/lib/DBIx/Class/ResultSourceProxy/Table.pm +++ b/lib/DBIx/Class/ResultSourceProxy/Table.pm @@ -6,7 +6,8 @@ use warnings; use base qw/DBIx::Class::ResultSourceProxy/; use DBIx::Class::ResultSource::Table; -use Scalar::Util (); +use Scalar::Util 'blessed'; +use namespace::clean; __PACKAGE__->mk_classdata(table_class => 'DBIx::Class::ResultSource::Table'); @@ -23,8 +24,11 @@ sub _init_result_source_instance { my $class_has_table_instance = ($table and $table->result_class eq $class); return $table if $class_has_table_instance; + my $table_class = $class->table_class; + $class->ensure_class_loaded($table_class); + if( $table ) { - $table = $class->table_class->new({ + $table = $table_class->new({ %$table, result_class => $class, source_name => undef, @@ -32,7 +36,7 @@ sub _init_result_source_instance { }); } else { - $table = $class->table_class->new({ + $table = $table_class->new({ name => undef, result_class => $class, source_name => undef, @@ -77,13 +81,18 @@ sub table { my ($class, $table) = @_; return $class->result_source_instance->name unless $table; - unless (Scalar::Util::blessed($table) && $table->isa($class->table_class)) { - $table = $class->table_class->new({ - $class->can('result_source_instance') ? - %{$class->result_source_instance||{}} : (), + unless (blessed $table && $table->isa($class->table_class)) { + + my $table_class = $class->table_class; + $class->ensure_class_loaded($table_class); + + $table = $table_class->new({ + $class->can('result_source_instance') + ? %{$class->result_source_instance||{}} + : () + , name => $table, result_class => $class, - source_name => undef, }); } @@ -95,14 +104,18 @@ sub table { return $class->result_source_instance->name; } +=head2 table_class + + __PACKAGE__->table_class('DBIx::Class::ResultSource::Table'); + +Gets or sets the table class used for construction and validation. + =head2 has_column if ($obj->has_column($col)) { ... } Returns 1 if the class has a column of this name, 0 otherwise. -=cut - =head2 column_info my $info = $obj->column_info($col); @@ -111,23 +124,23 @@ Returns the column metadata hashref for a column. For a description of the various types of column data in this hashref, see L -=cut - =head2 columns my @column_names = $obj->columns; -=cut +=head1 FURTHER QUESTIONS? -1; +Check the list of L. -=head1 AUTHORS +=head1 COPYRIGHT AND LICENSE -Matt S. Trout +This module is free software L +by the L. You can +redistribute it and/or modify it under the same terms as the +L. -=head1 LICENSE +=cut -You may distribute this code under the same terms as Perl itself. +1; -=cut