MooX::Role::CloneSet::BuildArgs - create updated copies of truly immutable objects
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');
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).
MooX::Role::CloneSet::BuildArgs
MooX::Role::CloneSet
cset()
MooX::BuildArgs
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.
build_args()
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.
Peter Pentchev <roam@ringlet.net>
To install MooX::Role::CloneSet, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooX::Role::CloneSet
CPAN shell
perl -MCPAN -e shell install MooX::Role::CloneSet
For more information on module installation, please visit the detailed CPAN module installation guide.