| 1 | package | ||
| 2 | Schema::Result; # Hide from PAUSE. This is just an example. | ||
| 3 | |||
| 4 | use strict; | ||
| 5 | use warnings; | ||
| 6 | |||
| 7 | use base 'DBIx::Class::Core'; | ||
| 8 | |||
| 9 | |||
| 10 | |||
| 11 | # Put useful things here which will be available from any Result:: class | ||
| 12 | __PACKAGE__->load_components(qw/ | ||
| 13 | InflateColumn::Serializer | ||
| 14 | InflateColumn::DateTime | ||
| 15 | InflateColumn::Boolean | ||
| 16 | /); | ||
| 17 | |||
| 18 | __PACKAGE__->true_is( qr/^(t|true|y|yes|on|1)$/i ); | ||
| 19 | |||
| 20 | |||
| 21 | |||
| 22 | sub is_created { shift->{ _created } } | ||
| 23 | |||
| 24 | |||
| 25 | 1; | ||
| 26 | |||
| 27 | =encoding utf8 | ||
| 28 | |||
| 29 | =head1 NAME | ||
| 30 | |||
| 31 | Schema::Result - Example base class for DBIx::Class result classes | ||
| 32 | |||
| 33 | =head1 DESCRIPTION | ||
| 34 | |||
| 35 | This module is an example base class for result classes in the shipped example | ||
| 36 | schema. | ||
| 37 | |||
| 38 | It loads common components: | ||
| 39 | |||
| 40 | - C<InflateColumn::Serializer> | ||
| 41 | - C<InflateColumn::DateTime> | ||
| 42 | - C<InflateColumn::Boolean> | ||
| 43 | |||
| 44 | and configures truthy values via C<true_is>. | ||
| 45 | |||
| 46 | =head1 METHODS | ||
| 47 | |||
| 48 | =head2 is_created | ||
| 49 | |||
| 50 | my $bool = $row->is_created; | ||
| 51 | |||
| 52 | Returns a boolean indicating that the row was created by L<D/C> in the current | ||
| 53 | process (it checks an internal C<_created> flag on the object). | ||
| 54 | |||
| 55 | =head1 SEE ALSO | ||
| 56 | |||
| 57 | L<DBIx::Class::Core>, L<Schema::ResultSet>, L<D> | ||
| 58 | |||
| 59 | =cut |