MooseX::BuildArgs - Save the original constructor arguments for later use.
Create a class that uses this module:
package MyClass; use Moose; use MooseX::BuildArgs; has foo => ( is=>'ro', isa=>'Str' ); my $object = MyClass->new( foo => 32 ); print $object->build_args->{foo};
Sometimes it is very useful to have access to the contructor arguments before builders, defaults, and coercion take affect. This module provides a build_args hashref attribute for all instances of the consuming class. The build_args attribute contains all arguments that were passed to the constructor.
A contrived case for this module would be for creating a clone of an object, so you could duplicate an object with the following code:
my $obj1 = MyClass->new( foo => 32 ); my $obj2 = MyClass->new( $obj1->build_args() ); print $obj2->foo();
Aran Clary Deltac <bluefeet@gmail.com>
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install MooseX::BuildArgs, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::BuildArgs
CPAN shell
perl -MCPAN -e shell install MooseX::BuildArgs
For more information on module installation, please visit the detailed CPAN module installation guide.