1package # hide from PAUSE 2 DSCTest::Schema::SourceDynamic; 3 4use base 'DBIx::Class'; 5 6__PACKAGE__->load_components(qw/DynamicSubclass Core/); 7__PACKAGE__->table('test2'); 8__PACKAGE__->add_columns( 9 id => { 10 data_type => 'int', 11 is_nullable => 0, 12 }, 13 type => { 14 data_type => 'smallint', 15 is_nullable => 1, 16 }, 17); 18 19__PACKAGE__->set_primary_key('id'); 20 21__PACKAGE__->typecast_column('type'); 22 23use DSCTest::Schema::SourceDynamic::Type1; 24use DSCTest::Schema::SourceDynamic::Type2; 25sub classify { 26 my $self = shift; 27 my $type = $self->type; 28 if (!$type) { 29 bless $self, __PACKAGE__; 30 } 31 elsif ($type == 1) { 32 bless $self, 'DSCTest::Schema::SourceDynamic::Type1', 33 } 34 else { 35 bless $self, 'DSCTest::Schema::SourceDynamic::Type2', 36 } 37} 38 391; 40