Venus::Unpack

Unpack Class

Unpack Class for Perl 5

method: all method: arg method: args method: array method: cast method: checks method: copy method: first method: from method: get method: into method: last method: list method: move method: name method: one method: reset method: set method: signature method: types method: use method: validate

package main;

use Venus::Unpack;

my $unpack = Venus::Unpack->new(args => ["hello", 123, 1.23]);

# my $args = $unpack->all->types('string', 'number', 'float')->args;

# ["hello", 123, 1.23]

This package provides methods for validating, coercing, and otherwise operating on lists of arguments.

Venus::Kind::Utility

The all method selects all arguments for processing returns the invocant.

all() (Venus::Unpack)

{ since => '2.01', }

=example-1 all

# given: synopsis

package main;

$unpack = $unpack->all;

# bless(..., 'Venus::Unpack')

The arg method returns the argument at the index specified.

arg(string $index) (any)

{ since => '2.01', }

=example-1 arg

# given: synopsis

package main;

my $arg = $unpack->arg(0);

# "hello"

The args method returns all arugments as an arrayref, or list in list context. If arguments are provided they will overwrite the existing arugment list.

args(any @args) (arrayref)

{ since => '2.01', }

=example-1 args

# given: synopsis

package main;

my $args = $unpack->args;

# ["hello", 123, 1.23]

The array method returns the argument list as a Venus::Array object.

array() (Venus::Array)

{ since => '2.01', }

=example-1 array

# given: synopsis

package main;

my $array = $unpack->array;

# bless(..., 'Venus::Array')

The cast method processes the selected arguments, passing each value to the class name specified, or the "cast" in Venus::Type method, and returns results.

cast(string $name) (arrayref)

{ since => '2.01', }

=example-1 cast

# given: synopsis

package main;

my $cast = $unpack->all->cast;

# [
#   bless(..., 'Venus::String'),
#   bless(..., 'Venus::Number'),
#   bless(..., 'Venus::Float'),
# ]

The checks method processes the selected arguments, passing each value to the "check" in Venus::Assert method with the type expression provided, and returns results.

checks(string @types) (arrayref)

{ since => '2.01', }

=example-1 checks

# given: synopsis

package main;

my $checks = $unpack->all->checks('string');

# [true, false, false]

The copy method copies values from the arugment list as properties of the underlying object and returns the invocant.

copy(string @pairs) (Venus::Unpack)

{ since => '2.01', }

=example-1 copy

# given: synopsis

package main;

$unpack = $unpack->copy(0 => 'arg1');

# bless({..., arg1 => 'hello'}, 'Venus::Unpack')

The first method selects the first argument for processing returns the invocant.

first() (Venus::Unpack)

{ since => '2.01', }

=example-1 first

# given: synopsis

package main;

$unpack = $unpack->first;

# bless(..., 'Venus::Unpack')

The from method names the source of the unpacking operation and is used in exception messages whenever the "signature" in Venus::Unpack operation fails. This method returns the invocant.

from(string $data) (Venus::Unpack)

{ since => '2.23', }

=example-1 from

# given: synopsis

package main;

$unpack = $unpack->from;

# bless(..., 'Venus::Unpack')

The get method returns the argument at the index specified.

get(string $index) (any)

{ since => '2.01', }

=example-1 get

# given: synopsis

package main;

my $get = $unpack->get;

# undef

The into method processes the selected arguments, passing each value to the class name specified, and returns results.

into(string @args) (any)

{ since => '2.01', }

=example-1 into

# given: synopsis

package main;

my $cast = $unpack->all->into('Venus::String');

# [
#   bless(..., 'Venus::String'),
#   bless(..., 'Venus::String'),
#   bless(..., 'Venus::String'),
# ]

The last method selects the last argument for processing returns the invocant.

last() (Venus::Unpack)

{ since => '2.01', }

=example-1 last

# given: synopsis

package main;

$unpack = $unpack->last;

# bless(..., 'Venus::Unpack')

The list method returns the result of the dispatched method call as an arrayref, or list in list context.

list(string | coderef $code, any @args) (arrayref)

{ since => '2.01', }

=example-1 list

# given: synopsis

package main;

my (@args) = $unpack->all->list('cast');

# (
#   bless(..., 'Venus::String'),
#   bless(..., 'Venus::Number'),
#   bless(..., 'Venus::Float'),
# )

The move method moves values from the arugment list, reducing the arugment list, as properties of the underlying object and returns the invocant.

move(string @pairs) (Venus::Unpack)

{ since => '2.01', }

=example-1 move

# given: synopsis

package main;

$unpack = $unpack->move(0 => 'arg1');

# bless({..., arg1 => 'hello'}, 'Venus::Unpack')

The name method names the unpacking operation and is used in exception messages whenever the "signature" in Venus::Unpack operation fails. This method returns the invocant.

name(string $data) (Venus::Unpack)

{ since => '2.23', }

=example-1 name

# given: synopsis

package main;

$unpack = $unpack->name;

# bless(..., 'Venus::Unpack')

The one method returns the first result of the dispatched method call.

one(string | coderef $code, any @args) (any)

{ since => '2.01', }

=example-1 one

# given: synopsis

package main;

my $one = $unpack->all->one('cast');

# (
#   bless(..., 'Venus::String'),
# )

The reset method resets the arugments list (if provided) and deselects all arguments (selected for processing) and returns the invocant.

reset(any @args) (Venus::Unpack)

{ since => '2.01', }

=example-1 reset

# given: synopsis

package main;

$unpack = $unpack->all->reset;

# bless(..., 'Venus::Unpack')

The set method assigns the value provided at the index specified and returns the value.

set(string $index, any $value) (any)

{ since => '2.01', }

=example-1 set

# given: synopsis

package main;

my $set = $unpack->set;

# ["hello", 123, 1.23]

The signature method processes the selected arguments, passing each value to the "validate" in Venus::Assert method with the type expression provided and throws an exception on failure and otherise returns the results as an arrayref, or as a list in list context.

signature(string $name, string @types) (arrayref)

{ since => '2.01', }

=example-1 signature

# given: synopsis

package main;

my ($string, $number, $float) = $unpack->all->name('example-1')->signature(
  'string | number | float',
);

# ("hello", 123, 1.23)

The types method processes the selected arguments, passing each value to the "validate" in Venus::Assert method with the type expression provided, and unlike the "validate" method returns the invocant.

types(string @types) (Venus::Unpack)

{ since => '2.01', }

=example-1 types

# given: synopsis

package main;

$unpack = $unpack->all->types('string | number | float');

# bless({...}, 'Venus::Unpack')

The use method selects the arguments specified (by index) for processing returns the invocant.

use(number @args) (Venus::Unpack)

{ since => '2.01', }

=example-1 use

# given: synopsis

package main;

$unpack = $unpack->use(1,2);

# bless(..., 'Venus::Unpack')

The validate method processes the selected arguments, passing each value to the "validate" in Venus::Assert method with the type expression provided and throws an exception on failure and otherise returns the resuts.

validate(string @types) (Venus::Unpack)

{ since => '2.01', }

=example-1 validate

# given: synopsis

package main;

my $results = $unpack->all->validate('string | number | float');

# ["hello", 123, 1.23]

t/Venus.t: present: authors t/Venus.t: present: license

115 POD Errors

The following errors were encountered while parsing the POD:

Around line 13:

Unknown directive: =name

Around line 21:

Unknown directive: =tagline

Around line 29:

Unknown directive: =abstract

Around line 37:

Unknown directive: =includes

Around line 66:

Unknown directive: =synopsis

Around line 91:

Unknown directive: =description

Around line 100:

Unknown directive: =inherits

Around line 108:

Unknown directive: =method

Around line 112:

Unknown directive: =signature

Around line 116:

Unknown directive: =metadata

Around line 143:

Unknown directive: =method

Around line 147:

Unknown directive: =signature

Around line 151:

Unknown directive: =metadata

Around line 187:

=cut found outside a pod block. Skipping to next block.

Around line 207:

=cut found outside a pod block. Skipping to next block.

Around line 217:

Unknown directive: =method

Around line 222:

Unknown directive: =signature

Around line 226:

Unknown directive: =metadata

Around line 262:

=cut found outside a pod block. Skipping to next block.

Around line 272:

Unknown directive: =method

Around line 276:

Unknown directive: =signature

Around line 280:

Unknown directive: =metadata

Around line 308:

Unknown directive: =method

Around line 313:

Unknown directive: =signature

Around line 317:

Unknown directive: =metadata

Around line 366:

=cut found outside a pod block. Skipping to next block.

Around line 381:

Unknown directive: =method

Around line 387:

Unknown directive: =signature

Around line 391:

Unknown directive: =metadata

Around line 427:

=cut found outside a pod block. Skipping to next block.

Around line 447:

=cut found outside a pod block. Skipping to next block.

Around line 467:

=cut found outside a pod block. Skipping to next block.

Around line 487:

=cut found outside a pod block. Skipping to next block.

Around line 497:

Unknown directive: =method

Around line 502:

Unknown directive: =signature

Around line 506:

Unknown directive: =metadata

Around line 546:

=cut found outside a pod block. Skipping to next block.

Around line 570:

=cut found outside a pod block. Skipping to next block.

Around line 584:

Unknown directive: =method

Around line 589:

Unknown directive: =signature

Around line 593:

Unknown directive: =metadata

Around line 620:

Unknown directive: =method

Around line 626:

Unknown directive: =signature

Around line 630:

Unknown directive: =metadata

Around line 667:

=cut found outside a pod block. Skipping to next block.

Around line 678:

Unknown directive: =method

Around line 682:

Unknown directive: =signature

Around line 686:

Unknown directive: =metadata

Around line 722:

=cut found outside a pod block. Skipping to next block.

Around line 742:

=cut found outside a pod block. Skipping to next block.

Around line 762:

=cut found outside a pod block. Skipping to next block.

Around line 782:

=cut found outside a pod block. Skipping to next block.

Around line 792:

Unknown directive: =method

Around line 797:

Unknown directive: =signature

Around line 801:

Unknown directive: =metadata

Around line 850:

=cut found outside a pod block. Skipping to next block.

Around line 879:

=cut found outside a pod block. Skipping to next block.

Around line 894:

Unknown directive: =method

Around line 899:

Unknown directive: =signature

Around line 903:

Unknown directive: =metadata

Around line 930:

Unknown directive: =method

Around line 935:

Unknown directive: =signature

Around line 939:

Unknown directive: =metadata

Around line 986:

=cut found outside a pod block. Skipping to next block.

Around line 1011:

=cut found outside a pod block. Skipping to next block.

Around line 1039:

=cut found outside a pod block. Skipping to next block.

Around line 1052:

Unknown directive: =method

Around line 1057:

Unknown directive: =signature

Around line 1061:

Unknown directive: =metadata

Around line 1101:

=cut found outside a pod block. Skipping to next block.

Around line 1125:

=cut found outside a pod block. Skipping to next block.

Around line 1139:

Unknown directive: =method

Around line 1145:

Unknown directive: =signature

Around line 1149:

Unknown directive: =metadata

Around line 1186:

=cut found outside a pod block. Skipping to next block.

Around line 1197:

Unknown directive: =method

Around line 1201:

Unknown directive: =signature

Around line 1205:

Unknown directive: =metadata

Around line 1246:

=cut found outside a pod block. Skipping to next block.

Around line 1257:

Unknown directive: =method

Around line 1262:

Unknown directive: =signature

Around line 1266:

Unknown directive: =metadata

Around line 1304:

=cut found outside a pod block. Skipping to next block.

Around line 1316:

Unknown directive: =method

Around line 1321:

Unknown directive: =signature

Around line 1325:

Unknown directive: =metadata

Around line 1361:

=cut found outside a pod block. Skipping to next block.

Around line 1381:

=cut found outside a pod block. Skipping to next block.

Around line 1401:

=cut found outside a pod block. Skipping to next block.

Around line 1421:

=cut found outside a pod block. Skipping to next block.

Around line 1431:

Unknown directive: =method

Around line 1438:

Unknown directive: =signature

Around line 1442:

Unknown directive: =metadata

Around line 1482:

=cut found outside a pod block. Skipping to next block.

Around line 1504:

=cut found outside a pod block. Skipping to next block.

Around line 1527:

=cut found outside a pod block. Skipping to next block.

Around line 1550:

=cut found outside a pod block. Skipping to next block.

Around line 1561:

Unknown directive: =method

Around line 1567:

Unknown directive: =signature

Around line 1571:

Unknown directive: =metadata

Around line 1607:

=cut found outside a pod block. Skipping to next block.

Around line 1629:

=cut found outside a pod block. Skipping to next block.

Around line 1652:

=cut found outside a pod block. Skipping to next block.

Around line 1663:

Unknown directive: =method

Around line 1668:

Unknown directive: =signature

Around line 1672:

Unknown directive: =metadata

Around line 1708:

=cut found outside a pod block. Skipping to next block.

Around line 1728:

=cut found outside a pod block. Skipping to next block.

Around line 1738:

Unknown directive: =method

Around line 1744:

Unknown directive: =signature

Around line 1748:

Unknown directive: =metadata

Around line 1784:

=cut found outside a pod block. Skipping to next block.

Around line 1804:

=cut found outside a pod block. Skipping to next block.

Around line 1825:

=cut found outside a pod block. Skipping to next block.

Around line 1836:

Unknown directive: =partials