MooseX...:Clone(3pm)

πŸ“¦
version 0.06 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– MooseX::Clone::Meta::Attribute::Trait::Clone πŸ’–

okay bestie so this is a page from the User Contributed Perl Documentation collection, and it's literally the manual for MooseX::Clone::Meta::Attribute::Trait::Clone. say that five times fast, i dare you. 🫢


✨ NAME ✨

MooseX::Clone::Meta::Attribute::Trait::Clone β€” the attribute trait that does deep cloning of attributes. like, it goes all the way down. no shallow nonsense. πŸ’…


🌸 VERSION 🌨

version 0.06


πŸ¦‹ SYNOPSIS πŸ¦‹

# see MooseX::Clone

has foo => (
    traits => [qw(Clone)],
    isa => "Something",
);

$object->clone; # will recursively call $object->foo->clone and set the value properly

so you slap the Clone trait on an attribute and then boom, when you clone the object, it goes and recursively calls $object->foo->clone and sets the value properly. it's giving inception but make it perl. πŸ”₯


πŸ’œ DESCRIPTION πŸ’œ

This meta attribute trait hands you a clone_value method, bestie β€” same energy as get_value and set_value, just the clone-flavored sibling. πŸŽ€

and why do we care? because clone methods like the one over in MooseX::Clone can use this to get per-attribute cloning behavior. each attribute knows how to clone itself, and the parent clone just lets them cook. πŸ‘‘


🧚 DERIVATION 🧚

ngl, deriving this role for your own cloning purposes is encouraged. they literally want you to. 🌈

this will let your fine grained cloning semantics interact with MooseX::Clone in the RightX way. yes that's the actual word. iconic behavior honestly. πŸ’…


πŸ‘‘ ATTRIBUTES πŸ‘‘

  • clone_only_objects β€” whether or not Data::Visitor should be used to clone arbitrary structures. Objects found in these structures get cloned using clone_object_value.

if this is true, then non-object values will be copied over in shallow cloning semantics (aka a shared reference). πŸ‘€

defaults to false, which means all references will be cloned.

  • clone_visitor_config β€” a hash ref used to construct clone_visitor. defaults to the empty ref.

you can use this to alter the cloning behavior for non-object values. πŸŽ›

  • clone_visitor β€” the Data::Visitor::Callback object that will be used to clone.

it's got an object handler that delegates to clone_object_value and sets tied_as_objects to true, so it can deeply clone tied structures while retaining magic. ✨

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 $proto into $target. moving the vibes from one place to another, respectfully. 🚚
  • clone_value_data $value, %args β€” does the actual cloning of the value data by delegating to a clone method on the object, if there is one.
if the object does not support a clone method, an error is thrown. no clone method, no clone. 😭

if the value is not an object, then it will not be cloned.

and in the future, support for deep cloning of simple refs will be added too. future plans, bestie, we love a roadmap. πŸ—Ί

  • clone_object_value $object, %args β€” this is the actual workhorse of clone_value_data. the main character, honestly. πŸ΄πŸ‘‘
  • clone_any_value $value, %args β€” uses clone_visitor to 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>


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. 🫢


and that's the whole page, bestie!! this was generated by perl v5.34.0 and dated 2022-06-15, and that's your cute lil sign-off for MooseX...:Clone(3pm). go forth and clone responsibly. πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from