use warnings;
use DBIx::Class::ResultSet;
-
+use SQL::Translator::Parser::DBIx::Class;
use base qw/DBIx::Class/;
__PACKAGE__->load_components(qw/ResultSource/);
__PACKAGE__->mk_group_accessors(
- 'simple' => qw(is_virtual view_definition depends_on)
-);
+ 'simple' => qw(is_virtual view_definition deploy_depends_on) );
=head1 NAME
An SQL query for your view. Will not be translated across database
syntaxes.
+=head2 deploy_depends_on
+
+ __PACKAGE__->result_source_instance->deploy_depends_on(
+ "MyDB::Schema::Result::Year","MyDB::Schema::Result::CD"
+ );
+
+Specify the result classes that comprise this view. Pass this
+method a list.
+
=head1 OVERRIDDEN METHODS
=head2 new
The constructor. This is a private method, as only other DBIC modules
-should call this. See L<DBIx::Class::ResultSource::MultipleTableInheritance>.
+should call this.
=cut
sub new {
- my $new = shift->next::method(@_);
- $new->{depends_on} = { %{$new->{depends_on}||{}} };
- return $new;
+ my ( $self, @args ) = @_;
+ my $new = $self->next::method(@args);
+ $new->{deploy_depends_on}
+ = { map { $_ => 1 } @{ ($new->{deploy_depends_on} || []) } };
+ use Data::Dumper;
+ print STDERR Dumper $new;
+ return $new;
}
=head2 from
=cut
sub from {
- my $self = shift;
- return \"(${\$self->view_definition})" if $self->is_virtual;
- return $self->name;
+ my $self = shift;
+ return \"(${\$self->view_definition})" if $self->is_virtual;
+ return $self->name;
}
=head1 PRIVATE METHODS
-=head2 depends_on
+=head2 deploy_depends_on
An internal method for the construction of a hashref of the view's
superclasses, e.g., the sources that comprise it.
-See L<DBIx::Class::ResultSource::MultipleTableInheritance>.
-
=cut
1;
Wallace Reis <wreis@cpan.org>
+Amiri Barksdale <amiri@metalabel.com>
+
=head1 LICENSE
You may distribute this code under the same terms as Perl itself.
use Test::Exception;
use lib qw(t/lib);
use ViewDeps;
+use Devel::Dwarn;
BEGIN {
use_ok('DBIx::Class::ResultSource::View');
isa_ok( $view, 'DBIx::Class::ResultSource', 'A new view');
isa_ok( $view, 'DBIx::Class', 'A new view also');
-can_ok( $view, $_ ) for qw/new from depends_on/;
+can_ok( $view, $_ ) for qw/new from deploy_depends_on/;
### DEPS
my $schema = ViewDeps->connect;
ok( $schema, 'Connected to ViewDeps schema OK' );
+my $bar_rs = $schema->resultset('Bar');
+#diag(DwarnS $bar_rs->result_source);
-my @bar_deps = keys %{ $schema->resultset('Bar')->result_source->depends_on };
+my @bar_deps = keys %{ $schema->resultset('Bar')->result_source->deploy_depends_on };
-my @foo_deps = keys %{ $schema->resultset('Foo')->result_source->depends_on };
+my @foo_deps = keys %{ $schema->resultset('Foo')->result_source->deploy_depends_on };
isa_ok( $schema->resultset('Bar')->result_source,
'DBIx::Class::ResultSource::View', 'Bar' );
"Baz on the other hand"
);
dies_ok {
- ViewDeps::Result::Baz->result_source_instance->depends_on(
+ ViewDeps::Result::Baz->result_source_instance->deploy_depends_on(
{ ViewDeps::Result::Mixin->result_source_instance->name => 1 } );
}
-"...and you cannot use depends_on with that";
+"...and you cannot use deploy_depends_on with that";
done_testing;
use strict;
use warnings;
-use parent qw(ViewDeps::Result::Foo);
+use base qw(ViewDeps::Result::Foo);
use ViewDeps::Result::Mixin;
+use ViewDeps::Result::Baz;
__PACKAGE__->table('bar');
-__PACKAGE__->result_source_instance->depends_on(
- { ViewDeps::Result::Mixin->result_source_instance->name => 1 }
+__PACKAGE__->result_source_instance->deploy_depends_on(
+ "ViewDeps::Result::Baz", "ViewDeps::Result::Mixin"
);
__PACKAGE__->add_columns(
use strict;
use warnings;
-use parent qw(DBIx::Class::Core);
+use base qw(DBIx::Class::Core);
__PACKAGE__->table('bar');
use strict;
use warnings;
-use parent qw(DBIx::Class::Core);
+use base qw(DBIx::Class::Core);
use aliased 'DBIx::Class::ResultSource::View';
__PACKAGE__->table_class(View);
use strict;
use warnings;
-use parent qw(DBIx::Class::Core);
+use base qw(DBIx::Class::Core);
__PACKAGE__->table('mixin');