NAME
Treex::Core::RememberArgs - role for remembering constructor's arguments
VERSION
version 2.20210102
SYNOPSIS
package MyClass;
use Moose;
with 'Treex::Core::RememberArgs';
has num => (is=>'rw');
1;
package Main;
use MyClass;
my $object = MyClass->({foo=>'bar baz', num=>42});
say $object->args_str;
# prints
# foo='bar baz' num=42
my $foo = $object->args->{foo};
DESCRIPTION
Moose role that saves all arguments that were passed to the constructor. These arguments are then available either as a hashref in attribute args
or as a string in form arg1=value1 arg2=val2 ... in attribute args_str
. Values containing spaces are enclosed in single quotes (and quotes inside the value escaped).
Unlike MooseX::SlurpyConstructor, this role stores also the arguments which are defined as attributes of the class (num
in the Synopsis).
Expected use cases: Treex scenarios need to serialize all the parameters and propagate them to nested scenarios. See e.g. Treex::Scen::EN2CS.
ATTRIBUTES
args
hash ref with the original arguments
args_str
stringified original arguments
SEE ALSO
AUTHOR
Martin Popel <popel@ufal.mff.cuni.cz>
COPYRIGHT AND LICENSE
Copyright © 2015 by Institute of Formal and Applied Linguistics, Charles University in Prague This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.