Venus::Role::Mappable

Mappable Role

Mappable Role for Perl 5

method: all method: any method: count method: delete method: each method: empty method: exists method: grep method: iterator method: keys method: map method: none method: one method: pairs method: random method: reverse method: slice

package Example;

use Venus::Class;

with 'Venus::Role::Mappable';

sub all;
sub any;
sub call;
sub count;
sub delete;
sub each;
sub empty;
sub exists;
sub grep;
sub iterator;
sub keys;
sub map;
sub none;
sub one;
sub pairs;
sub random;
sub reverse;
sub slice;

package main;

my $example = Example->new;

# $example->random;

This package provides a specification for the consuming package to implement methods that makes the object mappable. See Venus::Array and Venus::Hash as other examples of mappable classes.

The all method should return true if the callback returns true for all of the elements provided.

all(CodeRef $code) (Bool)

{ since => '0.01', }

=example-1 all

# given: synopsis;

my $all = $example->all(sub {
  # ...
});

The any method should return true if the callback returns true for any of the elements provided.

any(CodeRef $code) (Bool)

{ since => '0.01', }

=example-1 any

# given: synopsis;

my $any = $example->any(sub {
  # ...
});

The count method should return the number of top-level element in the data structure.

count() (Num)

{ since => '0.01', }

=example-1 count

# given: synopsis;

my $count = $example->count;

The delete method returns should remove the item in the data structure based on the key provided, returning the item.

delete(Str $key) (Any)

{ since => '0.01', }

=example-1 delete

# given: synopsis;

my $delete = $example->delete(...);

The each method should execute the callback for each item in the data structure passing the key and value as arguments.

each(CodeRef $code) (ArrayRef)

{ since => '0.01', }

=example-1 each

# given: synopsis;

my $results = $example->each(sub {
  # ...
});

The empty method should drop all items from the data structure.

empty() (Value)

{ since => '0.01', }

=example-1 empty

# given: synopsis;

my $empty = $example->empty;

The exists method should return true if the item at the key specified exists, otherwise it returns false.

exists(Str $key) (Bool)

{ since => '0.01', }

=example-1 exists

# given: synopsis;

my $exists = $example->exists(...);

The grep method should execute a callback for each item in the array, passing the value as an argument, returning a value containing the items for which the returned true.

grep(CodeRef $code) (ArrayRef)

{ since => '0.01', }

=example-1 grep

# given: synopsis;

my $results = $example->grep(sub {
  # ...
});

The iterator method should return a code reference which can be used to iterate over the data structure. Each time the iterator is executed it will return the next item in the data structure until all items have been seen, at which point the iterator will return an undefined value.

iterator() (CodeRef)

{ since => '0.01', }

=example-1 iterator

# given: synopsis;

my $iterator = $example->iterator;

The keys method should return an array reference consisting of the keys of the data structure.

keys() (ArrayRef)

{ since => '0.01', }

=example-1 keys

# given: synopsis;

my $keys = $example->keys;

The map method should iterate over each item in the data structure, executing the code reference supplied in the argument, passing the routine the value at the current position in the loop and returning an array reference containing the items for which the argument returns a value or non-empty list.

map(CodeRef $code) (ArrayRef)

{ since => '0.01', }

=example-1 map

# given: synopsis;

my $results = $example->map(sub {
  # ...
});

The none method should return true if none of the items in the data structure meet the criteria set by the operand and rvalue.

none(CodeRef $code) (Bool)

{ since => '0.01', }

=example-1 none

# given: synopsis;

my $none = $example->none(sub {
  # ...
});

The one method should return true if only one of the items in the data structure meet the criteria set by the operand and rvalue.

one(CodeRef $code) (Bool)

{ since => '0.01', }

=example-1 one

# given: synopsis;

my $one = $example->one(sub {
  # ...
});

The pairs method should return an array reference of tuples where each tuple is an array reference having two items corresponding to the key and value for each item in the data structure.

pairs(CodeRef $code) (Tuple[ArrayRef, ArrayRef])

{ since => '0.01', }

=example-1 pairs

# given: synopsis;

my $pairs = $example->pairs(sub {
  # ...
});

The random method should return a random item from the data structure.

random() (Any)

{ since => '0.01', }

=example-1 random

# given: synopsis;

my $random = $example->random;

The reverse method should returns an array reference containing the items in the data structure in reverse order if the items in the data structure are ordered.

reverse() (ArrayRef)

{ since => '0.01', }

=example-1 reverse

# given: synopsis;

my $reverse = $example->reverse;

The slice method should return a new data structure containing the elements in the invocant at the key(s) specified in the arguments.

slice(Str @keys) (ArrayRef)

{ since => '0.01', }

=example-1 slice

# given: synopsis;

my $slice = $example->slice(...);

t/Venus.t: pdml: authors t/Venus.t: pdml: license

58 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 61:

Unknown directive: =synopsis

Around line 105:

Unknown directive: =description

Around line 115:

Unknown directive: =method

Around line 120:

Unknown directive: =signature

Around line 124:

Unknown directive: =metadata

Around line 148:

Unknown directive: =method

Around line 154:

Unknown directive: =signature

Around line 158:

Unknown directive: =metadata

Around line 182:

Unknown directive: =method

Around line 188:

Unknown directive: =signature

Around line 192:

Unknown directive: =metadata

Around line 214:

Unknown directive: =method

Around line 220:

Unknown directive: =signature

Around line 224:

Unknown directive: =metadata

Around line 246:

Unknown directive: =method

Around line 252:

Unknown directive: =signature

Around line 256:

Unknown directive: =metadata

Around line 280:

Unknown directive: =method

Around line 285:

Unknown directive: =signature

Around line 289:

Unknown directive: =metadata

Around line 311:

Unknown directive: =method

Around line 317:

Unknown directive: =signature

Around line 321:

Unknown directive: =metadata

Around line 343:

Unknown directive: =method

Around line 350:

Unknown directive: =signature

Around line 354:

Unknown directive: =metadata

Around line 378:

Unknown directive: =method

Around line 386:

Unknown directive: =signature

Around line 390:

Unknown directive: =metadata

Around line 412:

Unknown directive: =method

Around line 418:

Unknown directive: =signature

Around line 422:

Unknown directive: =metadata

Around line 444:

Unknown directive: =method

Around line 452:

Unknown directive: =signature

Around line 456:

Unknown directive: =metadata

Around line 480:

Unknown directive: =method

Around line 486:

Unknown directive: =signature

Around line 490:

Unknown directive: =metadata

Around line 514:

Unknown directive: =method

Around line 520:

Unknown directive: =signature

Around line 524:

Unknown directive: =metadata

Around line 548:

Unknown directive: =method

Around line 555:

Unknown directive: =signature

Around line 559:

Unknown directive: =metadata

Around line 583:

Unknown directive: =method

Around line 588:

Unknown directive: =signature

Around line 592:

Unknown directive: =metadata

Around line 614:

Unknown directive: =method

Around line 621:

Unknown directive: =signature

Around line 625:

Unknown directive: =metadata

Around line 647:

Unknown directive: =method

Around line 653:

Unknown directive: =signature

Around line 657:

Unknown directive: =metadata

Around line 679:

Unknown directive: =partials