[Bast-commits] r9420 - in
DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps:
lib/DBIx/Class/ResultSource t t/lib/ViewDeps/Result
amiri at dev.catalyst.perl.org
amiri at dev.catalyst.perl.org
Mon May 24 15:31:31 GMT 2010
Author: amiri
Date: 2010-05-24 16:31:31 +0100 (Mon, 24 May 2010)
New Revision: 9420
Modified:
DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/lib/DBIx/Class/ResultSource/View.pm
DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/105view_deps.t
DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Bar.pm
DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Baz.pm
DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Foo.pm
DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Mixin.pm
Log:
In the middle of making deploy_depends_on smarter.
Modified: DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/lib/DBIx/Class/ResultSource/View.pm
===================================================================
--- DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/lib/DBIx/Class/ResultSource/View.pm 2010-05-23 17:08:31 UTC (rev 9419)
+++ DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/lib/DBIx/Class/ResultSource/View.pm 2010-05-24 15:31:31 UTC (rev 9420)
@@ -4,12 +4,11 @@
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
@@ -130,19 +129,32 @@
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
@@ -153,20 +165,18 @@
=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;
@@ -183,6 +193,8 @@
Wallace Reis <wreis at cpan.org>
+Amiri Barksdale <amiri at metalabel.com>
+
=head1 LICENSE
You may distribute this code under the same terms as Perl itself.
Modified: DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/105view_deps.t
===================================================================
--- DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/105view_deps.t 2010-05-23 17:08:31 UTC (rev 9419)
+++ DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/105view_deps.t 2010-05-24 15:31:31 UTC (rev 9420)
@@ -7,6 +7,7 @@
use Test::Exception;
use lib qw(t/lib);
use ViewDeps;
+use Devel::Dwarn;
BEGIN {
use_ok('DBIx::Class::ResultSource::View');
@@ -19,16 +20,18 @@
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' );
@@ -47,9 +50,9 @@
"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;
Modified: DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Bar.pm
===================================================================
--- DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Bar.pm 2010-05-23 17:08:31 UTC (rev 9419)
+++ DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Bar.pm 2010-05-24 15:31:31 UTC (rev 9420)
@@ -3,14 +3,15 @@
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(
Modified: DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Baz.pm
===================================================================
--- DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Baz.pm 2010-05-23 17:08:31 UTC (rev 9419)
+++ DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Baz.pm 2010-05-24 15:31:31 UTC (rev 9420)
@@ -4,7 +4,7 @@
use strict;
use warnings;
-use parent qw(DBIx::Class::Core);
+use base qw(DBIx::Class::Core);
__PACKAGE__->table('bar');
Modified: DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Foo.pm
===================================================================
--- DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Foo.pm 2010-05-23 17:08:31 UTC (rev 9419)
+++ DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Foo.pm 2010-05-24 15:31:31 UTC (rev 9420)
@@ -3,7 +3,7 @@
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);
Modified: DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Mixin.pm
===================================================================
--- DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Mixin.pm 2010-05-23 17:08:31 UTC (rev 9419)
+++ DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Mixin.pm 2010-05-24 15:31:31 UTC (rev 9420)
@@ -4,7 +4,7 @@
use strict;
use warnings;
-use parent qw(DBIx::Class::Core);
+use base qw(DBIx::Class::Core);
__PACKAGE__->table('mixin');
More information about the Bast-commits
mailing list