NAME
Mail::Builder::List - Helper module for handling various lists
SYNOPSIS
use Mail::Builder;
my $list = Mail::Builder::List->new('Mail::Builder::Address');
$list->add($address_object);
$list->add($another_address_object);
$list->reset;
$list->add($email,$name);
print $list->join(',');
DESCRIPTION
This is a helper module for handling various lists (e.g. recipient, attachment lists). The class contains convinient array/list handling functions.
METHODS
Constructor
new
my $list = Mail::Builder::List->new(CLASSNAME);
This constructor takes the class name of the objects it should hold. It is only possible to add objects of the given type. It is not possible to change the assigned type later.
convert
my $list = Mail::Builder::List->convert(ARRAYREF);
Constructor that converts an array reference into a Mail::Builder::List object. The list type is defined by the first element of the array.
Public Methods
length
Returns the number of items in the list.
add
$obj->add(OBJECT);
or
$obj->add(SCALAR VALUE/S)
Pushes a new item into the list. The methods either accepts an object or scalar values. Scalar values will be passed to the new
method in the list type class.
push
Synonym for add
remove
$obj->remove(OBJECT)
or
$obj->remove(SCALAR VALUE)
or
$obj->remove()
Removes the given element from the list. If no parameter is passed to the method the last element from the list will be removed instead.
reset
Removes all elements from the list, leaving an empty list.
item
my $list_item = $obj->item(INDEX)
Returns the list item with the given index.
join
my $list = $obj->join(STRING)
Serializes all items in the list and joins them using the given string.
has
$obj->has(OBJECT)
or
$obj->has(SCALAR VALUE)
Returns true if the given object is in the list. You can either pass an object or scalar value. Uses the compare method from the list type class.
Accessor
type
Returns the class name which was initially passed to the constructor.
list
Raw list as list or array reference.
AUTHOR
Maroš Kollár
CPAN ID: MAROS
maros [at] k-1.com
http://www.k-1.com
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 268:
Non-ASCII character seen before =encoding in 'Maroš'. Assuming UTF-8