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) (boolean)
{ 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) (boolean)
{ 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() (number)
{ 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(string $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(string $key) (boolean)
{ 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) (boolean)
{ 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) (boolean)
{ 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(string @keys) (arrayref)
{ since => '0.01', }
=example-1 slice
# given: synopsis;
my $slice = $example->slice(...);
t/Venus.t: present: authors t/Venus.t: present: license
58 POD Errors
The following errors were encountered while parsing the POD:
- Around line 14:
Unknown directive: =name
- Around line 22:
Unknown directive: =tagline
- Around line 30:
Unknown directive: =abstract
- Around line 38:
Unknown directive: =includes
- Around line 62:
Unknown directive: =synopsis
- Around line 106:
Unknown directive: =description
- Around line 116:
Unknown directive: =method
- Around line 121:
Unknown directive: =signature
- Around line 125:
Unknown directive: =metadata
- Around line 149:
Unknown directive: =method
- Around line 155:
Unknown directive: =signature
- Around line 159:
Unknown directive: =metadata
- Around line 183:
Unknown directive: =method
- Around line 189:
Unknown directive: =signature
- Around line 193:
Unknown directive: =metadata
- Around line 215:
Unknown directive: =method
- Around line 221:
Unknown directive: =signature
- Around line 225:
Unknown directive: =metadata
- Around line 247:
Unknown directive: =method
- Around line 253:
Unknown directive: =signature
- Around line 257:
Unknown directive: =metadata
- Around line 281:
Unknown directive: =method
- Around line 286:
Unknown directive: =signature
- Around line 290:
Unknown directive: =metadata
- Around line 312:
Unknown directive: =method
- Around line 318:
Unknown directive: =signature
- Around line 322:
Unknown directive: =metadata
- Around line 344:
Unknown directive: =method
- Around line 351:
Unknown directive: =signature
- Around line 355:
Unknown directive: =metadata
- Around line 379:
Unknown directive: =method
- Around line 387:
Unknown directive: =signature
- Around line 391:
Unknown directive: =metadata
- Around line 413:
Unknown directive: =method
- Around line 419:
Unknown directive: =signature
- Around line 423:
Unknown directive: =metadata
- Around line 445:
Unknown directive: =method
- Around line 453:
Unknown directive: =signature
- Around line 457:
Unknown directive: =metadata
- Around line 481:
Unknown directive: =method
- Around line 487:
Unknown directive: =signature
- Around line 491:
Unknown directive: =metadata
- Around line 515:
Unknown directive: =method
- Around line 521:
Unknown directive: =signature
- Around line 525:
Unknown directive: =metadata
- Around line 549:
Unknown directive: =method
- Around line 556:
Unknown directive: =signature
- Around line 560:
Unknown directive: =metadata
- Around line 584:
Unknown directive: =method
- Around line 589:
Unknown directive: =signature
- Around line 593:
Unknown directive: =metadata
- Around line 615:
Unknown directive: =method
- Around line 622:
Unknown directive: =signature
- Around line 626:
Unknown directive: =metadata
- Around line 648:
Unknown directive: =method
- Around line 654:
Unknown directive: =signature
- Around line 658:
Unknown directive: =metadata
- Around line 680:
Unknown directive: =partials