Gungho::Response - Gungho HTTP Response Object


Gungho documentation Contained in the Gungho distribution.

Index


Code Index:

NAME

Top

Gungho::Response - Gungho HTTP Response Object

DESCRIPTION

Top

This module is exactly the same as HTTP::Response, but adds notes()

METHODS

Top

new

clone

notes


Gungho documentation Contained in the Gungho distribution.

# $Id$
#
# Copyright (c) 2007 Daisuke Maki <daisuke@endeworks.jp>
# All rights reserved.

package Gungho::Response;
use strict;
use warnings;
use base qw(HTTP::Response);
use Storable qw(dclone);

sub new
{
    my $class = shift;
    my $self  = $class->SUPER::new(@_);
    $self->{_notes} = {};
    return $self;
}

sub clone
{
    my $self  = shift;
    my $clone = $self->SUPER::clone;
    my $cloned_notes = dclone $self->notes;
    foreach my $note (keys %$cloned_notes) {
        $clone->notes( $note => $cloned_notes->{$note} );
    }
    return $clone;
}

sub notes
{
    my $self = shift;
    my $key  = shift;

    return $self->{_notes} unless $key;

    my $value = $self->{_notes}{$key};
    if (@_) {
        $self->{_notes}{$key} = $_[0];
    }
    return $value;
}

1;

__END__