| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Amazon::MWS::Enumeration; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 2 |  |  | 5 |  | 63821 | use strict; | 
|  | 2 |  |  |  |  | 2 |  | 
|  | 2 |  |  |  |  | 54 |  | 
| 4 | 2 |  |  | 5 |  | 8 | use warnings; | 
|  | 2 |  |  |  |  | 2 |  | 
|  | 2 |  |  |  |  | 50 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 | 2 |  |  | 5 |  | 7 | use Exporter; | 
|  | 2 |  |  |  |  | 2 |  | 
|  | 2 |  |  |  |  | 159 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | use overload ( | 
| 9 |  |  |  |  |  |  | '""'  => \&as_string, | 
| 10 | 9 |  |  | 12 |  | 1907 | 'cmp' => sub { "$_[0]" cmp $_[1] }, | 
| 11 | 2 |  |  | 5 |  | 1288 | ); | 
|  | 2 |  |  |  |  | 1018 |  | 
|  | 2 |  |  |  |  | 25 |  | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | sub as_string { | 
| 14 | 14 |  |  | 17 | 1 | 148 | my $self = shift; | 
| 15 | 14 |  |  |  |  | 123 | return $$self; | 
| 16 |  |  |  |  |  |  | } | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | sub define { | 
| 19 | 3 |  |  | 6 | 1 | 12 | my $class = shift; | 
| 20 | 2 |  |  | 5 |  | 188 | no strict 'refs'; | 
|  | 2 |  |  |  |  | 2 |  | 
|  | 2 |  |  |  |  | 320 |  | 
| 21 |  |  |  |  |  |  |  | 
| 22 | 3 |  |  |  |  | 6 | *{"${class}::import"} = *Exporter::import; | 
|  | 3 |  |  |  |  | 21 |  | 
| 23 |  |  |  |  |  |  |  | 
| 24 | 3 |  |  |  |  | 8 | foreach my $const (@_) { | 
| 25 | 22 |  |  |  |  | 17 | my $string = $const; | 
| 26 | 22 |  |  |  |  | 20 | my $ref    = \$string; | 
| 27 | 22 |  |  |  |  | 25 | bless $ref, $class; | 
| 28 |  |  |  |  |  |  |  | 
| 29 | 22 |  |  | 13 |  | 40 | *{"${class}::$const"} = sub { $ref }; | 
|  | 22 |  |  | 3 |  | 78 |  | 
|  | 10 |  |  | 3 |  | 3831 |  | 
|  |  |  |  | 3 |  |  |  | 
|  |  |  |  | 3 |  |  |  | 
|  |  |  |  | 3 |  |  |  | 
|  |  |  |  | 3 |  |  |  | 
| 30 | 22 |  |  |  |  | 19 | push @{"${class}::EXPORT_OK"}, $const; | 
|  | 22 |  |  |  |  | 41 |  | 
| 31 | 22 |  |  |  |  | 24 | push @{ ${"${class}::EXPORT_TAGS"}{'all'} }, $const; | 
|  | 22 |  |  |  |  | 18 |  | 
|  | 22 |  |  |  |  | 87 |  | 
| 32 |  |  |  |  |  |  | } | 
| 33 |  |  |  |  |  |  | } | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | 1; | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | __END__ | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | =head1 NAME | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | Amazon::MWS::Enumeration | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | Base class for enumeration values that stringify to themselves, used to | 
| 46 |  |  |  |  |  |  | represent the various enum values defined in the MWS api.  Using these instead | 
| 47 |  |  |  |  |  |  | of just raw strings buys you compile-time checking to make sure you didn't | 
| 48 |  |  |  |  |  |  | misspell the rather long all-caps names. | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | use Amazon::MWS::Enumeration::FeedType qw(:all); | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  | _POST_PRODUCT_DATA_ # no warnings or strict violations, checked for typos! | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | =head1 METHODS | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | =head2 define ( @constants ) | 
| 59 |  |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | For each string passed, installs a class method / exportable sub into the | 
| 61 |  |  |  |  |  |  | calling subclass by that name.  The value returned by that sub will be an | 
| 62 |  |  |  |  |  |  | object blessed into the calling package which stringifies into the constant | 
| 63 |  |  |  |  |  |  | itself, e.g. $class->CONSTANT eq 'CONSTANT'; | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | =head2 as_string () | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | The stringifier for these enums - simply dereferences the blessed scalar. | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | =head1 AUTHOR | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | Paul Driver C<< frodwith@cpan.org >> | 
| 72 |  |  |  |  |  |  |  | 
| 73 |  |  |  |  |  |  | =head1 LICENCE AND COPYRIGHT | 
| 74 |  |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  | Copyright (c) 2009, Plain Black Corporation L<http://plainblack.com>. | 
| 76 |  |  |  |  |  |  | All rights reserved | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | This module is free software; you can redistribute it and/or modify it under | 
| 79 |  |  |  |  |  |  | the same terms as Perl itself.  See L<perlartistic>. |