The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Array::Delegate - Perl extension for delegating methods calls on a ArrayRef to its elements

SYNOPSIS

    package Employee;

    sub new { my $class = shift; return bless {@_}, $class; }

    sub pay_salary { print "Yay, fresh money for", shift->{name}, "\n" }

    package Company;

    sub employees {
        return Array::Delegate->new( [Employee->new( name => 'Tim' ), Employee->new( name => 'Bob' )] );
    }

    package SomeModule;

    Company->new()->employees()->pay_salary(); # pays all employees

DESCRIPTION

This is just to create a bit of syntactict sugar for OO interfaces.

In a a method that normally returns an ArrayRef of Objects, you can return an instance of Array::Delegate, which is still and array, just blessed. Then, the caller can use

    $results = $array->foo

Instead of

        $results = [ map $_->foo, @$array ];

METHODS

new( $arrayRef )

Simply blesses $arrayRef to be a Array::Delegate object.

AUTHOR

Alaska Saedelere, <alaska.saedelere@googlemail.com<gt>

COPYRIGHT AND LICENSE

Copyright (C) 2009 by Alaska Saedelere

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.