package NSDL::Response;

# Copyright 2005 Norman Walsh. This work is licensed under a
# Creative Commons License: http://creativecommons.org/licenses/by-nc/2.0/

use strict;

use overload fallback => 1, '""' => "_value";

sub new {
    my $type = shift;
    my $xml = shift;
    my $self = {};
    $self->{'xml'} = $xml;
    return bless $self, $type;
}

sub _xml {
    my $self = shift;
    return $self->{'xml'};
}

sub _value {
    my $self = shift;
    return $self->{'default'};
}

sub addValue {
    my $self = shift;
    my $name = shift;
    my $value = shift;
    my $subname = $name;

    $self->{'default'} = $value unless exists $self->{'default'};

    no strict 'refs';

    *$subname = sub {
	my $self = shift;
	return $value;
    }
}

1;
