Data::Object::Role::Arguable
Arguable Role for Perl 5 Plugin Classes
package Example; use Moo; with 'Data::Object::Role::Arguable'; has name => ( is => 'ro' ); has options => ( is => 'ro' ); sub argslist { ('name', '@options') } package main; my $example = Example->new(['james', 'red', 'white', 'blue']);
This package provides a mechanism for unpacking an argument list and creating a data structure suitable for passing to the consumer constructor. The argslist routine should return a list of attribute names in the order to be parsed. An attribute name maybe prefixed with "@" to denote that all remaining items should be assigned to an arrayref, e.g. @options, or "%" to denote that all remaining items should be assigned to a hashref, e.g. %options.
argslist
@options
%options
This package uses type constraints from:
Types::Standard
This package implements the following methods:
packargs() : HashRef
The packargs method uses argslist to return a data structure suitable for passing to the consumer constructor.
package main; my $example = Example->new; my $attributes = $example->packargs('james', 'red', 'white', 'blue');
unpackargs(Any @args) : (Any)
The unpackargs method uses argslist to return a list of arguments from the consumer class instance in the appropriate order.
package main; my $example = Example->new(['james', 'red', 'white', 'blue']); my $arguments = [$example->unpackargs];
Al Newkirk, awncorp@cpan.org
awncorp@cpan.org
Copyright (C) 2011-2019, Al Newkirk, et al.
This is free software; you can redistribute it and/or modify it under the terms of the The Apache License, Version 2.0, as elucidated in the "license file".
Wiki
Project
Initiatives
Milestones
Contributing
Issues
To install Data::Object::Role::Arguable, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Object::Role::Arguable
CPAN shell
perl -MCPAN -e shell install Data::Object::Role::Arguable
For more information on module installation, please visit the detailed CPAN module installation guide.