| 1 | package InterMine::Model::Role::Descriptor; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | InterMine::Model::Role::Descriptor - Provides the common behaviour of descriptors | ||
| 6 | |||
| 7 | =head1 SYNOPSIS | ||
| 8 | |||
| 9 | use Moose; | ||
| 10 | with 'InterMine::Model::Role::Descriptor'; | ||
| 11 | |||
| 12 | =cut | ||
| 13 | |||
| 14 | use MooseX::Role::WithOverloading; | ||
| 15 | use InterMine::Model::Types qw(Model); | ||
| 16 | |||
| 17 | requires qw(to_string); | ||
| 18 | |||
| 19 | =head1 OVERLOADING | ||
| 20 | |||
| 21 | =over 4 | ||
| 22 | |||
| 23 | =item STRINGIFICATION | ||
| 24 | |||
| 25 | Descriptors must implement a "to_string" method, which is | ||
| 26 | called when string overloading occurs. | ||
| 27 | |||
| 28 | =item COMPARISON | ||
| 29 | |||
| 30 | Descriptors sort according to their (uppercased) names | ||
| 31 | |||
| 32 | =cut | ||
| 33 | |||
| 34 | use overload ( | ||
| 35 | '""' => 'to_string', | ||
| 36 | fallback => 1, | ||
| 37 | ); | ||
| 38 | |||
| 39 | =back | ||
| 40 | |||
| 41 | =head1 ATTRIBUTES | ||
| 42 | |||
| 43 | =head2 model (Model, ro, required) | ||
| 44 | |||
| 45 | The model for this descriptor | ||
| 46 | |||
| 47 | =cut | ||
| 48 | |||
| 49 | has model => ( | ||
| 50 | is => 'ro', | ||
| 51 | isa => Model, | ||
| 52 | required => 1, | ||
| 53 | weak_ref => 1, | ||
| 54 | ); | ||
| 55 | |||
| 56 | 1; | ||
| 57 | |||
| 58 | =head1 AUTHOR | ||
| 59 | |||
| 60 | FlyMine C<< <support@flymine.org> >> | ||
| 61 | |||
| 62 | =head1 BUGS | ||
| 63 | |||
| 64 | Please report any bugs or feature requests to C<support@flymine.org>. | ||
| 65 | |||
| 66 | =head1 SUPPORT | ||
| 67 | |||
| 68 | You can find documentation for this module with the perldoc command. | ||
| 69 | |||
| 70 | perldoc InterMine::Model::Role::Descriptor | ||
| 71 | |||
| 72 | You can also look for information at: | ||
| 73 | |||
| 74 | =over 4 | ||
| 75 | |||
| 76 | =item * FlyMine | ||
| 77 | |||
| 78 | L<http://www.flymine.org> | ||
| 79 | |||
| 80 | =back | ||
| 81 | |||
| 82 | =head1 COPYRIGHT & LICENSE | ||
| 83 | |||
| 84 | Copyright 2006,2007,2008,2009,2010 FlyMine, all rights reserved. | ||
| 85 | |||
| 86 | This program is free software; you can redistribute it and/or modify it | ||
| 87 | under the same terms as Perl itself. |