NAME
Data::Object::Role::Immutable
ABSTRACT
Data-Object Immutability Role
SYNOPSIS
package Entity;
use Data::Object 'Class';
with 'Data::Object::Role::Immutable';
has 'name';
method BUILD($args) {
$self->immutable;
return $args;
}
1;
DESCRIPTION
This package provides a mechanism for making any Data::Object data type object immutable. An immutable object is an object whose state cannot be modified after it is created; Immutable objects are often useful because they are inherently thread-safe, easier to reason about, and offer higher security than mutable objects.
METHODS
This package implements the following methods.
immutable
immutable() : Object
The immutable method returns the invocant but will throw an error if an attempt is made to modify the underlying value.