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

MooseX::MultiObject::Meta::Method::MultiDelegation - method that delegates to a set of objects

VERSION

version 0.03

SYNOPSIS

Given a class that has a set of objects:

my $meta = Moose::Meta::Class->create( ... );
$meta->add_attribute ( objects => (
    is => 'ro', isa => 'Set', handles => ['members'],
);

Make a method foo to call foo on every element of the set:

my $foo_metamethod = MooseX::MultiObject::Meta::Method::MultiDelegation->new(
    object_getter => 'members',
    delegate_to   => 'foo',
);

$meta->add_method( foo => $foo_metamethod );

Then you can write:

my $class = $meta->name->new( objects => [ $a, $b ] );
my @results = $class->foo;

Which is equivalent to:

my $set = set($a, $b);
my @results = map { $_->foo } $set->members;

DESCRIPTION

This is a Moose::Meta::Method and Class::MOP::Method::Generated that works like Moose::Meta::Method::Delegation, except it delegates to a collection of objects instead of just one.

INITARGS

curried_arguments

delegate_to

object_getter

AUTHOR

Jonathan Rockway <jrockway@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2011 by Jonathan Rockway.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.