package WWW::Extractor::Generic::Object;

use strict;
use vars qw(@ISA $AUTOLOAD);

@ISA = qw|Exporter|;

# generic constructor
sub new {
    my $pkg = shift;
    bless { @_ }, $pkg;
}

sub DESTROY {
    # to prevent autoloader trying to indirect it!
}

# automatic get/set method!
# should probably re-write this... it doesn't check the package properly
sub AUTOLOAD {
    my ($self, $v) = @_;
    my $key = (split /::/, $AUTOLOAD)[-1];
    if (exists $self->{$key}) {
	$self->{$key} = $v if $#_ > 0;
	$self->{$key};
    } else {
	die "attempted to call undefined method $AUTOLOAD from ".join ' ', caller;
    }
}

sub as_string {
    my $self = shift;
    '{' . (join ', ', map "$_=>".$self->{$_}, keys %$self) . '}';
}

1
