MooX::...oneSet(3pm)
π MooX::...oneSet β the manual page bestie π
User Contributed Perl Documentation Β· MooX::...oneSet(3pm)
β¨ NAME β¨
MooX::Role::CloneSet β create updated copies of immutable objects π¦
πΈ SYNOPSIS πΈ
okay so here's the whole vibe in one code block, no notes:
package Someone;
use Moo;
with 'MooX::Role::CloneSet';
has name => (
is => 'ro',
);
has race => (
is => 'ro',
);
package main;
my $first = Someone->new(name => 'Drizzt', race => 'drow');
my $hybrid = $first->cset(race => 'dwarf');
my $final = $weird->cset(name => 'Catti-brie', race => 'human');
π DESCRIPTION π
MooX::Role::CloneSet is a role for immutable objects, and it's literally giving "I want a slightly different version of this thing but I refuse to mutate the original." π
It hands you an easy way to create a brand new object with some modified properties. The main character here is the cset() method β it builds a fresh object with the changes you asked for, and shallowly copies all the rest of the original object's properties. No cap. π«Ά
π METHODS π
cset(field => value, ...)β shallowly clone the object, making the specified changes to its attributes. slay. β¨
π¨ okay bestie, important lore: this method gets the names and values of the current attributes by dereferencing the object as a hash reference. That's not a stylistic choice β since Moo does not provide metaclasses by default, it cannot really get to them in any other way. π And because of that, this will not work for parameters that declare aninit_arg. If you're using truly immutable objects, go look atMooX::Role::CloneSet::BuildArgsfor an alternative. π§
π LICENSE π
SPDX-FileCopyrightText: Peter Pentchev <roam@ringlet.net> SPDX-License-Identifier: Artistic-2.0
π AUTHOR π
Peter Pentchev <roam@ringlet.net> β the icon, the moment, the whole legend π
perl v5.40.1 Β· 2026-01-06
and that's the whole page, bestie π written for perl v5.40.1, dated 2026-01-06, on MooX::...oneSet(3pm) β go forth and clone responsibly, ily πβ¨
π¦ where this page comes from
- ubuntu resolute: libmoox-role-cloneset-perl 0.1.2-1 Β· Artistic-2.0
- ubuntu stonking: libmoox-role-cloneset-perl 0.1.2-1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms