| 1 | package Catalyst::Plugin::MobileAgent; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | use NEXT; | ||
| 6 | use Catalyst::Request; | ||
| 7 | use HTTP::MobileAgent; | ||
| 8 | |||
| 9 | our $VERSION = '0.041'; | ||
| 10 | |||
| 11 | { | ||
| 12 | package Catalyst::Request; | ||
| 13 | |||
| 14 | sub mobile_agent { | ||
| 15 | my $self = shift; | ||
| 16 | unless ( $self->{ mobile_agent } ) { | ||
| 17 | $self->{ mobile_agent } = HTTP::MobileAgent->new( $self->headers ); | ||
| 18 | } | ||
| 19 | return $self->{ mobile_agent }; | ||
| 20 | } | ||
| 21 | } | ||
| 22 | |||
| 23 | =head1 NAME | ||
| 24 | |||
| 25 | Catalyst::Plugin::MobileAgent - HTTP mobile user agent string parser plugin for Catalyst | ||
| 26 | |||
| 27 | =head1 SYNOPSIS | ||
| 28 | |||
| 29 | use Catalyst 'MobileAgent'; | ||
| 30 | |||
| 31 | if ($c->request->mobile_agent->is_docomo) { | ||
| 32 | # do something | ||
| 33 | } | ||
| 34 | |||
| 35 | =head1 DESCRIPTION | ||
| 36 | |||
| 37 | Catalyst plugin parsed user agent string for mobile in Japan. | ||
| 38 | |||
| 39 | =head1 EXTENDED METHODS | ||
| 40 | |||
| 41 | =head2 prepare_headers | ||
| 42 | |||
| 43 | Sets mobile_agent using L<HTTP::MobileAgent>. | ||
| 44 | |||
| 45 | =head1 METHODS | ||
| 46 | |||
| 47 | =head2 mobile_agent | ||
| 48 | |||
| 49 | Returns an instance of HTTP::MobileAgent. | ||
| 50 | |||
| 51 | =head1 SEE ALSO | ||
| 52 | |||
| 53 | L<HTTP::MobileAgent>, L<Catalyst::Request> | ||
| 54 | |||
| 55 | =head1 AUTHOR | ||
| 56 | |||
| 57 | Yoshiki Kurihara, C<< <kurihara at cpan.org> >> | ||
| 58 | |||
| 59 | =head1 LICENSE | ||
| 60 | |||
| 61 | This library is free software; you can redistribute it and/or modify | ||
| 62 | it under the same terms as Perl itself. | ||
| 63 | |||
| 64 | =cut | ||
| 65 | |||
| 66 | 1; # End of Catalyst::Plugin::MobileAgent |