1 package DBIx::Class::ResultClass::HashRefInflator;
8 DBIx::Class::ResultClass::HashRefInflator
12 my $rs = $schema->resultset('CD');
14 $rs->result_class('DBIx::Class::ResultClass::HashRefInflator');
18 DBIx::Class is not built for speed: it's built for convenience and
19 ease of use. But sometimes you just need to get the data, and skip the
20 fancy objects. That is what this class provides.
22 There are two ways of using this class.
28 Specify C<< $rs->result_class >> on a specific resultset to affect only that
29 resultset (and any chained off of it); or
33 Specify C<< __PACKAGE__->result_class >> on your source object to force all
34 uses of that result source to be inflated to hash-refs - this approach is not
43 Inflates the result and prefetched data into a hash-ref using L<mk_hash>.
48 my ($self, $source, $me, $prefetch) = @_;
50 return mk_hash($me, $prefetch);
55 This does all the work of inflating the (pre)fetched data.
62 # $me is the hashref of cols/data from the immediate resultsource
63 # $rest is a deep hashref of all the data from the prefetched
66 # to avoid emtpy has_many rels contain one empty hashref
67 return undef if (not keys %$me);
71 foreach (values %$me) {
77 return undef unless $def;
82 ref($rest->{$_}[0]) eq 'ARRAY'
83 ? [ grep defined, map mk_hash(@$_), @{$rest->{$_}} ]
84 : mk_hash( @{$rest->{$_}} )