También hemos extendido la subrutina AUTOLOAD para que
compruebe (líneas 74 y 82) que el método de acceso requerido
está permitido.
71 sub AUTOLOAD {
72 no strict "refs";
73 my $self = shift;
74 if (($AUTOLOAD =~ /\w+::\w+::get(_.*)/) && ($self->_accesible($1,'read'))) {
75 my $n = $1;
76 die "Error in $AUTOLOAD: Illegal attribute\n" unless exists $self->{$n};
77
78 # Declarar el metodo get_*****
79 *{$AUTOLOAD} = sub { return $_[0]->{$n}; };
80
81 return $self->{$n};
82 } elsif (($AUTOLOAD =~ /\w+::\w+::set(_.*)/) && ($self->_accesible($1,'write'))) {
83 my $n = $1;
84 die "Error in $AUTOLOAD: Illegal attribute\n" unless exists $self->{$n};
85 $self->{$n} = shift;
86
87 # Declarar el metodo set_*****
88 *{$AUTOLOAD} = sub { $_[0]->{$n} = $_[1]; };
89 } else {
90 die "Error: Function $AUTOLOAD not found\n";
91 }
Casiano Rodríguez León
