MooX::...oneSet(3pm)

πŸ“¦
version 0.1.2 Β· 4 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– 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 an init_arg. If you're using truly immutable objects, go look at MooX::Role::CloneSet::BuildArgs for 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