++ed by:
1 non-PAUSE user
Author image James A. Duncan
and 1 contributors


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


  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 {
  if ($@) {
    if ($@->isa('EO::Error::Method::NotFound') {
      # ... handle method not found exception
    } else {
      # ... handle other exceptions


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.



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.


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


Copyright 2003 Fotango Ltd. All Rights Reserved.

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