A simple wrapper to allow callbacks to a method on an object.
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2025-09-20 13:25:55 +02:00
dist Initial Commit 2025-09-20 13:25:55 +02:00
lib/Object Initial Commit 2025-09-20 13:25:55 +02:00
LICENSE Initial Commit 2025-09-20 13:25:55 +02:00
Makefile.PL Initial Commit 2025-09-20 13:25:55 +02:00
README.md Initial Commit 2025-09-20 13:25:55 +02:00

NAME

Object::Callback - Wrapper to allow callback to a method on an object

VERSION

version 1.0

SYNOPSIS

use Object::Callback;
use Simple::Log;
use Funky::Log;

my (@listeners);
push @listeners,
    Object::Callback( 'object' => Simple::Log->new( 'file' => '/tmp/junk' ),
                        'method' => 'logline' ),
    Object::Callback( 'object' => Funky::Log->new( 'style' => 'purple with spots' ),
                        'method' => 'jam_this_somewhere' );

while(<>)
{
    $line = $_;
    chomp $line;
    map { $_->callback( $line ); } @listeners;
}

DESCRIPTION

Object::Callback is a simple helper to allow callback to a method on a specific object.

Taking a reference to an object method does not provide the capability to indicate which object this reference should be applied to. Basic perl callback simply handles the code reference and no associated context. To allow for the grouping of both the required object and the method we create an Object::Callback object which contains the required information in a single composite.

COMPATIBILITY

  • Object::Callback requires Class::Accessorize::All.

AUTHOR

Bernard Quatermass toolsmith@quatermass.co.uk

COPYRIGHT AND LICENSE

This software is copyright (c) 2025 by Bernard Quatermass.

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