++ed by:

1 non-PAUSE user.

James A. Duncan
and 1 contributors

NAME

EO::delegate - delegate responsibility for unresolved messages to another class

SYNOPSIS

  package Foo;
  use EO;
  our @ISA = qw( EO );
  use EO::delegate;

  package main;

  my $thing = Foo->new();
  $thing->delegate( SomeClass->new() );
  $thing->delegate_error( 'throw' );

  eval {
    $thing->some_method;
  };
  if ($@) {
    if ($@->isa('EO::Error::Method::NotFound') {
      # ... handle method not found exception
    } else {
      # ... handle other exceptions
    }
  }

DESCRIPTION

EO::delegate provides a simple means of setting up a delegate for the a class. By importing this package into your namespace you have two new methods available to you - the delegate method, which gets and sets the delegate, and the delegate_error method, which gets and sets the method to call on the exception if any are raised.

By default delegate_error will be set to 'throw', but it may be useful to set it to 'record' if you don't wish the delegate to cause your program to die.

EXCEPTIONS

EO::Error::Method::NotFound

In the case that a method that is forwarded to a delegate is not available in that delegate an EO::Error::Method::NotFound exception is thrown or recorded, depending on whether delegate_error returns throw or record.

AUTHOR

  James A. Duncan <jduncan@fotango.com>
  Arthur Bergman <abergman@fotango.com>

COPYRIGHT

Copyright 2003 Fotango Ltd. All Rights Reserved.

This module is released under the same terms as Perl itself.