Skip to content

Instantly share code, notes, and snippets.

@anazawa
Created March 30, 2012 02:52
Show Gist options
  • Select an option

  • Save anazawa/2246049 to your computer and use it in GitHub Desktop.

Select an option

Save anazawa/2246049 to your computer and use it in GitHub Desktop.
好みの問題?
{
my %method_of = (
get => \&Blosxom::Header::get_header,
set => \&Blosxom::Header::set_header,
exists => \&Blosxom::Header::exists_header,
delete => \&Blosxom::Header::delete_header,
push => \&Blosxom::Header::push_header,
);
while ( my ( $method, $sub_ref ) = each %method_of ) {
no strict 'refs';
*$method = sub {
my ( $self, @args ) = @_;
$sub_ref->( $self->{header}, @args );
};
}
}
# 同値 (にみえる)
sub get { Blosxom::Header::get_header( shift->{header}, @_ ) }
sub set { Blosxom::Header::set_header( shift->{header}, @_ ) }
sub exists { Blosxom::Header::exists_header( shift->{header}, @_ ) }
sub delete { Blosxom::Header::delete_header( shift->{header}, @_ ) }
sub push { Blosxom::Header::push_header( shift->{header}, @_ ) }
# 迷わず後者を選択する
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment