1 package DBIx::Class::ResultClass::HashRefInflator;
5 DBIx::Class::ResultClass::HashRefInflator
9 my $rs = $schema->resultset('CD');
11 $rs->result_class('DBIx::Class::ResultClass::HashRefInflator');
15 DBIx::Class is not built for speed: it's built for convenience and
16 ease of use. But sometimes you just need to get the data, and skip the
17 fancy objects. That is what this class provides.
19 There are two ways of using this class.
25 Specify C<< $rs->result_class >> on a specific resultset to affect only that
26 resultser (and any chained off of it); or
30 Specify C<< __PACKAGE__->result_class >> on your source object to force all
31 uses of that result source to be inflated to hash-refs - this approach is not
40 Inflates the result and prefetched data into a hash-ref using L<mk_hash>.
45 my ($self, $source, $me, $prefetch) = @_;
47 return mk_hash($me, $prefetch);
52 This does all the work of inflating the (pre)fetched data.
59 # $me is the hashref of cols/data from the immediate resultsource
60 # $rest is a deep hashref of all the data from the prefetched
63 # to avoid emtpy has_many rels contain one empty hashref
64 return if (not keys %$me);
68 foreach (values %$me) {
79 ref($rest->{$_}[0]) eq 'ARRAY' ? [ map { mk_hash(@$_) } @{$rest->{$_}} ]
80 : mk_hash( @{$rest->{$_}} )