inflator working transparently
Luke Saunders [Mon, 16 Aug 2010 10:28:26 +0000 (12:28 +0200)]
lib/DBIx/Class/ResultSet/WithMetaData.pm
lib/DBIx/Class/WithMetaData/Inflator.pm [new file with mode: 0644]

index d460542..01a9853 100644 (file)
@@ -141,9 +141,11 @@ resulting data merged with them.
 
 method display () {
   my $rs = $self->search({});
-  $rs->result_class('DBIx::Class::ResultClass::HashRefInflator');
+#  $rs->result_class('DBIx::Class::ResultClass::HashRefInflator');
+  $rs->result_class('DBIx::Class::WithMetaData::Inflator');
   my @rows;
-  foreach my $row ($rs->all) {
+  foreach my $row_rep ($rs->all) {
+    my ($row, $row_obj) = @{$row_rep};
     # THIS BLOCK IS DEPRECATED
     if (my $info = $self->row_info_for(id => $self->_mk_id(row => $row))) {
       $row = { %{$row}, %{$info} };
diff --git a/lib/DBIx/Class/WithMetaData/Inflator.pm b/lib/DBIx/Class/WithMetaData/Inflator.pm
new file mode 100644 (file)
index 0000000..6f42dd0
--- /dev/null
@@ -0,0 +1,21 @@
+package DBIx::Class::WithMetaData::Inflator;
+
+use strict;
+use warnings;
+use Moose;
+extends 'DBIx::Class::ResultClass::HashRefInflator';
+
+around inflate_result => sub {
+  my $orig = shift;
+  my $self = shift;
+
+  my $hash = $self->$orig(@_);
+
+  my ($source, @rest) = @_;
+  my $row =  $source->result_class->inflate_result(@_);
+  warn $row;
+  warn $self;
+  return [$hash, $row];
+};
+
+1;