1 package DBIx::Class::ResultSet::HashRef;
5 use base qw( DBIx::Class::ResultSet );
6 use DBIx::Class::ResultClass::HashRefInflator;
8 our $VERSION = '1.000';
12 DBIx::Class::ResultSet::HashRef - Adds syntatic sugar to skip the fancy objects
16 # in your resultsource class
17 __PACKAGE__->resultset_class( 'DBIx::Class::ResultSet::HashRef' );
19 # in your calling code
20 my $rs = $schema->resultset('User')->search( { } )->hashref_rs;
21 while (my $row = $rs->next) {
25 You can chain up every L<DBIx::Class::ResultSet> method to ->hashref_rs:
27 * ->hashref_rs->all (same as ->hashref_array)
29 * ->hashref_rs->first (same as ->hashref_first)
33 This is a simple way to allow you to set result_class to L<DBIx::Class::ResultClass::HashRefInflator> to
34 skip the fancy objects.
47 Sets result_class to L<DBIx::Class::ResultClass::HashRefInflator> and returns the resultset.
53 $self->result_class('DBIx::Class::ResultClass::HashRefInflator');
57 =head2 hashref_array( )
59 Calls ->hashref_rs->all and returns depending on the calling context an array or an reference to an array.
61 my $rs = $schema->resultset('User')->search( { } )->hashref_array;
64 my @rs = $schema->resultset('User')->search( { } )->hashref_array;
70 return wantarray ? shift->hashref_rs->all : [ shift->hashref_rs->all ];
73 =head2 hashref_first( )
75 Returns the first row of the resultset inflated by L<DBIx::Class::ResultClass::HashRefInflator>.
77 my $first_row = $schema->resultset('User')->search( { } )->hashref_first;
78 print Dumper $first_row
83 return shift->hashref_rs->first;
88 Johannes Plunien E<lt>plu@cpan.orgE<gt>
90 =head1 COPYRIGHT AND LICENSE
92 Copyright 2008 by Johannes Plunien
94 This library is free software; you can redistribute it and/or modify
95 it under the same terms as Perl itself.
97 Thanks to mst for his patience.
103 =item * L<DBIx::Class>
105 =item * L<DBIx::Class::ResultClass::HashRefInflator>