| Package-Transporter documentation | view source | Contained in the Package-Transporter distribution. |
Package::Transporter::Generator::Potential::Get_Set_Methods - Automatically created accessors and mutators
use Package::Transporter sub{eval shift}, sub {
$_[0]->register_drain('::Random', 'FOR_SELF',
'ATB_', qw(WORLD));
$_[0]->register_potential('::Get_Set_Methods', 'FOR_ANY');
};
my $obj = bless( {}, 'main');
$obj->set_world(1); # $obj->{+ATB_WORLD} = 1
use Data::Dumper;
print STDERR Dumper($obj);
exit(0);
The above example enables accessors and mutators for objects globally. The random keys for the hash are really nice, aren't they?!
The same example for objects implemented via arrays.
use Package::Transporter sub{eval shift}, sub {
$_[0]->register_drain('::Enumerated', 'FOR_SELF',
'ATB_', qw(WORLD));
$_[0]->register_potential('::Get_Set_Methods', 'FOR_ANY');
};
my $obj = bless( [], 'main');
$obj->set_world(1); # $obj->[ATB_WORLD] = 1
use Data::Dumper;
print STDERR Dumper($obj);
exit(0);
Please see the documentation of the upstream package Package::Transporter.
| Package-Transporter documentation | view source | Contained in the Package-Transporter distribution. |