add files
|
1 |
package Mojo::Cookie; |
2 |
use Mojo::Base -base; |
|
3 |
use overload bool => sub {1}, '""' => sub { shift->to_string }, fallback => 1; |
|
4 | ||
5 |
use Carp 'croak'; |
|
6 | ||
7 |
has [qw(name value)]; |
|
8 | ||
9 |
sub parse { croak 'Method "parse" not implemented by subclass' } |
|
10 |
sub to_string { croak 'Method "to_string" not implemented by subclass' } |
|
11 | ||
12 |
1; |
|
13 | ||
14 |
=encoding utf8 |
|
15 | ||
16 |
=head1 NAME |
|
17 | ||
18 |
Mojo::Cookie - HTTP cookie base class |
|
19 | ||
20 |
=head1 SYNOPSIS |
|
21 | ||
22 |
package Mojo::Cookie::MyCookie; |
|
23 |
use Mojo::Base 'Mojo::Cookie'; |
|
24 | ||
25 |
sub parse {...} |
|
26 |
sub to_string {...} |
|
27 | ||
28 |
=head1 DESCRIPTION |
|
29 | ||
30 |
L<Mojo::Cookie> is an abstract base class for HTTP cookies as described in RFC |
|
31 |
6265. |
|
32 | ||
33 |
=head1 ATTRIBUTES |
|
34 | ||
35 |
L<Mojo::Cookie> implements the following attributes. |
|
36 | ||
37 |
=head2 name |
|
38 | ||
39 |
my $name = $cookie->name; |
|
40 |
$cookie = $cookie->name('foo'); |
|
41 | ||
42 |
Cookie name. |
|
43 | ||
44 |
=head2 value |
|
45 | ||
46 |
my $value = $cookie->value; |
|
47 |
$cookie = $cookie->value('/test'); |
|
48 | ||
49 |
Cookie value. |
|
50 | ||
51 |
=head1 METHODS |
|
52 | ||
53 |
L<Mojo::Cookie> inherits all methods from L<Mojo::Base> and implements the |
|
54 |
following new ones. |
|
55 | ||
56 |
=head2 parse |
|
57 | ||
58 |
my $cookies = $cookie->parse($str); |
|
59 | ||
60 |
Parse cookies. Meant to be overloaded in a subclass. |
|
61 | ||
62 |
=head2 to_string |
|
63 | ||
64 |
my $str = $cookie->to_string; |
|
65 |
my $str = "$cookie"; |
|
66 | ||
67 |
Render cookie. Meant to be overloaded in a subclass. |
|
68 | ||
69 |
=head1 SEE ALSO |
|
70 | ||
71 |
L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicio.us>. |
|
72 | ||
73 |
=cut |