The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Zing::Table - Entity Lookup Table

ABSTRACT

Entity Lookup Table Construct

SYNOPSIS

use Zing::Table;

my $table = Zing::Table->new(name => 'users');

# my $domain = $table->set('unique-id');

DESCRIPTION

This package provides an index and lookup-table for Zing::Repo derived data structures which provides the ability to create a collection of repo objects.

INHERITS

This package inherits behaviors from:

Zing::Channel

LIBRARIES

This package uses type constraints from:

Zing::Types

ATTRIBUTES

This package has the following attributes:

position

position(Maybe[Int])

This attribute is read-write, accepts (Maybe[Int]) values, and is optional.

type

type(TableType)

This attribute is read-only, accepts (TableType) values, and is optional.

METHODS

This package implements the following methods:

count

count() : Int

The count method returns the number of Zing::Repo objects in the table.

count example #1
# given: synopsis

$table->count;
count example #2
# given: synopsis

$table->set('user-12345');

$table->count;

drop

drop() : Int

The drop method returns truthy if the table has been destroyed. This operation does not cascade.

drop example #1
# given: synopsis

$table->drop;

fetch

fetch(Int $size = 1) : ArrayRef[Repo]

The fetch method returns the next n Zing::Repo objects from the table.

fetch example #1
# given: synopsis

$table->fetch;
fetch example #2
# given: synopsis

$table->set('user-12345');
$table->set('user-12346');
$table->set('user-12347');

$table->fetch(5);

first

first() : Maybe[Repo]

The first method returns the first Zing::Repo object created in the table.

first example #1
# given: synopsis

$table->first;

get

get(Str $key) : Maybe[Repo]

The get method returns the Zing::Repo associated with a specific key.

get example #1
# given: synopsis

$table->get('user-12345');
head() : Maybe[Repo]

The head method returns the first Zing::Repo object created in the table.

head example #1
# given: synopsis

$table->head;

index

index(Int $position) : Maybe[Repo]

The index method returns the Zing::Repo object at the position (index) specified.

index example #1
# given: synopsis

$table->index(0);

last

last() : Maybe[Repo]

The last method returns the last Zing::Repo object created in the table.

last example #1
# given: synopsis

$table->last;

next

next() : Maybe[Repo]

The next method returns the next Zing::Repo object created in the table.

next example #1
# given: synopsis

$table->next;
next example #2
# given: synopsis

$table->position(undef);

$table->prev;
$table->prev;
$table->next;
next example #3
# given: synopsis

$table->position($table->size);

$table->prev;
$table->next;
$table->prev;

prev

prev() : Maybe[Repo]

The prev method returns the previous Zing::Repo object created in the table.

prev example #1
# given: synopsis

$table->prev;
prev example #2
# given: synopsis

$table->next;
$table->next;
$table->prev;
prev example #3
# given: synopsis

$table->position($table->size);

$table->next;
$table->next;
$table->prev;
prev example #4
# given: synopsis

$table->position(undef);

$table->next;
$table->prev;
$table->next;

renew

renew() : Int

The renew method returns truthy if it resets the internal cursor, otherwise falsy.

renew example #1
# given: synopsis

$table->renew;

reset

reset() : Int

The reset method always reset the internal cursor and return truthy.

reset example #1
# given: synopsis

$table->reset;

set

set(Str $key) : Repo

The set method creates a Zing::Repo association with a specific key in the table. The key should be unique. Adding the same key will result in duplicate entries.

set example #1
# given: synopsis

$table->set('user-12345');

tail

tail() : Maybe[Repo]

The tail method returns the last Zing::Repo object created in the table.

tail example #1
# given: synopsis

$table->tail;

term

term() : Str

The term method returns the name of the table.

term example #1
# given: synopsis

$table->term;

AUTHOR

Al Newkirk, awncorp@cpan.org

LICENSE

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".

PROJECT

Wiki

Project

Initiatives

Milestones

Contributing

Issues