| 1 | package DBIx::Class::Helpers; | ||
| 2 | $DBIx::Class::Helpers::VERSION = '2.032002'; | ||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | # ABSTRACT: Simplify the common case stuff for DBIx::Class. | ||
| 7 | |||
| 8 | 1; # this class isn't meant to be used | ||
| 9 | |||
| 10 | __END__ | ||
| 11 | |||
| 12 | =pod | ||
| 13 | |||
| 14 | =head1 NAME | ||
| 15 | |||
| 16 | DBIx::Class::Helpers - Simplify the common case stuff for DBIx::Class. | ||
| 17 | |||
| 18 | =head1 SYNOPSIS | ||
| 19 | |||
| 20 | package MyApp::Schema::Result::Foo_Bar; | ||
| 21 | |||
| 22 | __PACKAGE__->load_components(qw{Helper::JoinTable Core}); | ||
| 23 | |||
| 24 | __PACKAGE__->join_table({ | ||
| 25 | left_class => 'Foo', | ||
| 26 | left_method => 'foo', | ||
| 27 | right_class => 'Bar', | ||
| 28 | right_method => 'bar', | ||
| 29 | }); | ||
| 30 | |||
| 31 | # define parent class | ||
| 32 | package ParentSchema::Result::Bar; | ||
| 33 | |||
| 34 | use strict; | ||
| 35 | use warnings; | ||
| 36 | |||
| 37 | use parent 'DBIx::Class'; | ||
| 38 | |||
| 39 | __PACKAGE__->load_components('Core'); | ||
| 40 | |||
| 41 | __PACKAGE__->table('Bar'); | ||
| 42 | |||
| 43 | __PACKAGE__->add_columns(qw/ id foo_id /); | ||
| 44 | |||
| 45 | __PACKAGE__->set_primary_key('id'); | ||
| 46 | |||
| 47 | __PACKAGE__->belongs_to( foo => 'ParentSchema::Result::Foo', 'foo_id' ); | ||
| 48 | |||
| 49 | # define subclass | ||
| 50 | package MySchema::Result::Bar; | ||
| 51 | |||
| 52 | use strict; | ||
| 53 | use warnings; | ||
| 54 | |||
| 55 | use parent 'ParentSchema::Result::Bar'; | ||
| 56 | |||
| 57 | __PACKAGE__->load_components(qw{Helper::SubClass Core}); | ||
| 58 | |||
| 59 | __PACKAGE__->subclass; | ||
| 60 | |||
| 61 | =head1 SEE ALSO | ||
| 62 | |||
| 63 | L<DBIx::Class::Helper::Row::JoinTable>, L<DBIx::Class::Helper::Row::SubClass>, L<DBIx::Class::Helpers::Util> | ||
| 64 | |||
| 65 | =head1 AUTHOR | ||
| 66 | |||
| 67 | Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com> | ||
| 68 | |||
| 69 | =head1 COPYRIGHT AND LICENSE | ||
| 70 | |||
| 71 | This software is copyright (c) 2016 by Arthur Axel "fREW" Schmidt. | ||
| 72 | |||
| 73 | This is free software; you can redistribute it and/or modify it under | ||
| 74 | the same terms as the Perl 5 programming language system itself. | ||
| 75 | |||
| 76 | =cut |