The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Package::Transporter::Generator::Potential::Get_Set_Methods - Automatically created accessors and mutators

SYNOPSIS

        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);

DESCRIPTION

The above example enables accessors and mutators for objects globally. The random keys for the hash are really nice, aren't they?!

Objects via Arrays

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);

ANYTHING ELSE

Please see the documentation of the upstream package Package::Transporter.