return undef;
}
$self = $parent->new($call, @_);
+ $self->register;
$parent->_addnode($self);
return $self;
}
@out = $uref->addparent($self);
} else {
$uref = Route::User->new($ucall, $self->{call}, @_);
+ $uref->register;
@out = $uref;
}
$self->_adduser($uref);
{
my $pkg = shift;
my $call = uc shift;
-
- confess "already have $call in $pkg" if $list{$call};
-
my $self = $pkg->SUPER::new($call);
$self->{parent} = ref $pkg ? [ $pkg->{call} ] : [ ];
$self->{version} = shift;
$self->{nodes} = [];
$self->{lid} = 0;
- $list{$call} = $self;
-
return $self;
}
+sub register
+{
+ my $self = shift;
+ confess "already have $call in $pkg" if $list{$self->{call}};
+ $list{$call} = $self;
+}
+
sub get
{
my $call = shift;
sub AUTOLOAD
{
no strict;
- my $name = $AUTOLOAD;
+
+ my $self = shift;
+ $name = $AUTOLOAD;
return if $name =~ /::DESTROY$/;
- $name =~ s/^.*:://o;
+ $name =~ s/.*:://o;
confess "Non-existant field '$AUTOLOAD'" unless $valid{$name} || $Route::valid{$name};
- # this clever line of code creates a subroutine which takes over from autoload
- # from OO Perl - Conway
- *$AUTOLOAD = sub {$_[0]->{$name} = $_[1] if @_ > 1; return $_[0]->{$name}};
- goto &$AUTOLOAD;
+ *$AUTOLOAD = sub {@_ > 1 ? $_[0]->{$name} = $_[1] : $_[0]->{$name}};
+ &$AUTOLOAD($self, @_);
}
1;