Created
February 4, 2012 04:51
-
-
Save anazawa/1735425 to your computer and use it in GitHub Desktop.
make accessors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for my $field (qw(type nph expires cookie charset attachment p3p)) { | |
| my $slot = __PACKAGE__."::$field"; | |
| my $code = sub { | |
| my $self = shift; | |
| my $value = shift; | |
| if ($value) { | |
| $self->set($field => $value); | |
| } | |
| else { | |
| my @values = $self->get($field); | |
| wantarray ? @values : $values[0]; | |
| } | |
| }; | |
| no strict 'refs'; | |
| *$slot = $code; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment