all_from 'lib/DBIx/Class/ResultSet/WithMetaData.pm';
requires 'DBIx::Class' => 0.08;
-requires 'MooseX::Method::Signatures' => 0.13;
+requires 'MooseX::Method::Signatures' => 0.16;
+requires 'Data::Alias';
+requires 'DBIx::Class::ResultClass::HashRefInflator;
build_requires 'Test::More' => 0.7;
isa => 'Int'
);
+has 'id_cols' => (
+ is => 'rw',
+ isa => 'ArrayRef',
+);
+
+
sub new {
my $self = shift;
- my $new = $self->next::method(@_);
- foreach my $key (qw/_row_info/) {
+
+ my $new = $self->next::method(@_);
+ foreach my $key (qw/_row_info was_row id_cols/) {
alias $new->{$key} = $new->{attrs}{$key};
- $new->{$key} = {} unless $new->{$key};
}
- return $new;
-}
+ unless ($new->_row_info) {
+ $new->_row_info({});
+ }
-method with_token {
- foreach my $row ($self->all) {
- my $token = $self->tokenify($row->get_column($self->token_col));
- $self->add_row_info(id => $row->id, info => { join('_', 'token', $self->token_col) => $token });
+ unless ($new->id_cols && scalar(@{$new->id_cols})) {
+ $new->id_cols([sort $new->result_source->primary_columns]);
}
- return $self;
+ return $new;
}
method display () {
$rs->result_class('DBIx::Class::ResultClass::HashRefInflator');
my @rows;
foreach my $row ($rs->all) {
- if (my $info = $self->row_info_for(id => $row->{id})) {
+ if (my $info = $self->row_info_for(id => $self->_mk_id(row => $row))) {
$row = { %{$row}, %{$info} };
}
push(@rows, $row);
return $self->search({}, { rows => $count });
}
+method with_token {
+ foreach my $row ($self->all) {
+ my $token = $self->tokenify($row->get_column($self->token_col));
+ $self->add_row_info(id => $row->id, info => { join('_', 'token', $self->token_col) => $token });
+ }
+
+ return $self;
+}
+
+method _mk_id (HashRef :$row) {
+ return join('-', map { $row->{$_} } @{$self->id_cols});
+}
+
+
sub tokenify {
my ($self, $string) = @_;
# set up and populate schema
ok(my $schema = DBICTest->init_schema(), 'got schema');
+my $producer_rs = $schema->resultset('Producer')->display();
+warn Dumper($producer_rs);