MooseX...eClone(3pm)
π MooseX::Clone::Meta::Attribute::Trait::StorableClone π
okay so bestie, welcome to the User Contributed Perl Documentation section, and this little icon is MooseX::Clone::Meta::Attribute::Trait::StorableClone. long name? yes. worth it? also yes. it's the attribute trait that deep-clones your attributes using Storable, and honestly it's giving main character energy for like six lines of code. π
β¨ VERSION β¨
version 0.06 β vintage but iconic, no cap. π¦
πΈ SYNOPSIS πΈ
# see MooseX::Clone
has foo => (
traits => [qw(StorableClone)],
isa => "Something",
);
my $clone = $object->clone; # $clone->foo will equal Storable::dclone($object->foo)
so you slap the trait on, and boom π
the clone comes out deep-copied, $clone->foo equals Storable::dclone($object->foo).
π¦ DESCRIPTION π¦
This meta attribute trait hands you a clone_value method, and it lives in the same friend group as get_value and set_value. which means clone methods β like the one over in MooseX::Clone β can use this per-attribute cloning behavior. it's giving pluggable cloning, fr fr. β¨
π DERIVATION π
Deriving this role for your own cloning purposes is encouraged. periodt. π«Ά
This will let your fine grained cloning semantics interact with MooseX::Clone in the RightX way. iykyk. π
π ATTRIBUTES π
clone_only_objectsβ Whether or notData::Visitorshould be used to clone arbitrary structures. Objects found in these structures will be cloned usingclone_object_value.
If true then non object values will be copied over in shallow cloning semantics (shared reference). π yes, shared. be normal about it.
Defaults to false (all reference will be cloned).
clone_visitor_configβ A hash ref used to constructclone_visitor. Defaults to the empty ref.
This can be used to alter the cloning behavior for non object values.
clone_visitorβ TheData::Visitor::Callbackobject that will be used to clone.
It has an object handler that delegates to clone_object_value and sets tied_as_objects to true in order to deeply clone tied structures while retaining magic. π§ magic retained, as a treat.
Only used if clone_only_objects is false and the value of the attribute is not an object.
β METHODS β
clone_value $target, $proto, %argsβ Clones the value the attribute encapsulates from$protointo$target. π«‘clone_value_data $value, %argsβ Does the actual cloning of the value data by delegating to aclonemethod on the object if any.
If the object does not support a clone method an error is thrown. π so like, don't.
If the value is not an object then it will not be cloned.
In the future support for deep cloning of simple refs will be added too. (future plans, not current facts, bestie β manifesting β¨)
clone_object_value $object, %argsβ This is the actual workhorse ofclone_value_data. π the one doing all the heavy lifting while everyone else takes credit.clone_any_value $value, %argsβ Usesclone_visitorto clone all non object values.
Called from clone_value_data if the value is not an object and clone_only_objects is false.
π AUTHOR π
XXXX XXX'XX (Yuval Kogman) <nothingmuch@woobling.org> β shoutout to the legend, we love to see it. π
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2008 by XXXX XXX'XX (Yuval Kogman).
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. slay. π
ok that's the whole thing, no details skipped, every flag and method accounted for. go forth and clone responsibly. π
and finally, the cute little sign-off: this was perl v5.34.0, dated 2022-06-15. bye bestie, mwah πβ¨
π¦ where this page comes from
- debian bookworm: libmoosex-clone-perl 0.06-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libmoosex-clone-perl 0.06-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmoosex-clone-perl 0.06-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmoosex-clone-perl 0.06-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmoosex-clone-perl 0.06-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms