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

Raisin::Attributes - Simple attributes accessors for Raisin.

SYNOPSIS

use Raisin::Attributes;

has hello => sub { 'hello' };
warn $self->hello;

has 'new';
warn $self->new;

has key => 'value';
warn $self->key;

DESCRIPTION

Simple implementation of attribute accessors.

METHODS

has

This code:

has key => 'value';

Will produce:

sub key {
    my ($self, $value) = @_;
    $self->{_key} = $value if defined $value;
    return $self->{_key} // 'value';
}