logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

MooX::Role::CloneSet::BuildArgs - create updated copies of truly immutable objects

Author

       Peter Pentchev <roam@ringlet.net>

perl v5.40.0                                       2024-12-31               MooX::Role::CloneSet::BuildArgs(3pm)

Description

       "MooX::Role::CloneSet::BuildArgs" is a role very similar to "MooX::Role::CloneSet"; the only difference
       is that its cset() method does not try to obtain the current values of the object's attributes, but uses
       the ones the object was constructed with (using "MooX::BuildArgs").

License

       Copyright (C) 2016  Peter Pentchev <roam@ringlet.net>

       This  library  is  free  software;  you can redistribute it and/or modify it under the same terms as Perl
       itself.

Methods

       •   cset(field => value, ...)

           Shallowly clone the object, making the specified changes to its attributes.

           Note  that  this  method  obtains  the  names  and  values  of  the  object's attributes by using the
           build_args() method from "MooX::BuildArgs"; thus, it really depends on the  fact  that  none  of  the
           attributes has had its value changed since the object was constructed.

Name

       MooX::Role::CloneSet::BuildArgs - create updated copies of truly immutable objects

Synopsis

           package Someone;

           use Moo;
           with 'MooX::Role::CloneSet::BuildArgs';

           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');

See Also