NAME
MooseX::AttributeCloner
VERSION
0.13
SYNOPSIS
package My::Class;
use Moose;
with qw{MooseX::AttributeCloner};
my $NewClassObject = $self->new_with_cloned_attributes(q{New::Class}, {});
1;
DESCRIPTION
The purpose of this Role is to take all the attributes which have values in the current class, and populate them directly into a new class object. The purpose of which is that if you have data inputted on the command line that needs to propagate through to later class objects, you shouldn't need to do the following
my $oNewClass = New::Class->new({
attr1 => $self->attr1,
attr2 => $self->attr2,
...
});
Which is going to get, quite frankly, tedious in the extreme. Particularly when you have more 2 class objects in your chain.
SUBROUTINES/METHODS
new_with_cloned_attributes
This takes a package name as the first argument, plus an optional additional $arg_refs hash. It will return a class object of the package populated with any matching attribute data from the current object, plus anything in the $arg_refs hash.
attributes_as_json
returns all the built attributes that are not objects as a JSON string
my $sAttributesAsJSON = $class->attributes_as_json();
attributes_as_escaped_json
as attributes_as_json, except it is an escaped JSON string, so that this could be used on a command line
my $sAttributesAsEscapedJSON = $class->attributes_as_escaped_json();
This uses JSON to generate the string, removing any objects before stringifying, and then parses it through a regex to generate a string with escaped characters Note, because objects are removed, arrays will remain the correct length, but have null in them
DIAGNOSTICS
CONFIGURATION AND ENVIRONMENT
DEPENDENCIES
INCOMPATIBILITIES
BUGS AND LIMITATIONS
This is more than likely to have bugs in it. Please contact me with any you find (or submit to RT) and any patches.
AUTHOR
setitesuk
LICENSE AND COPYRIGHT
Copyright (C) 2009 Andy Brown (setitesuk@gmail.com)
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.