Name : perl-Class-Decorator
| |
Version : 0.99
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : 8.63
| Date : 2024-08-05 19:11:33
|
Group : Development/Libraries/Perl
| Source RPM : perl-Class-Decorator-0.99-8.63.src.rpm
|
Size : 0.01 MB
| |
Packager : (none)
| |
Summary : Attach additional responsibilites to an object. A generic wrapper
|
Description :
Decorator objects allow additional functionality to be dynamically added to objects. In this implementation, the user can supply two subroutine references (pre and post) to be performed before (pre) and after (post) any method call to an object (obj).
Both \'pre\' and \'post\' arguments to the contructor are optional. The \'obj\' argument is mandated.
The pre and post methods receive the arguments that are supplied to the decorated method, and therefore Class::Decorator can be used effectively in debugging or logging applications. Return values from pre and post are ignored.
Decorator objects can themselves be decorated. Therefore, it is possible to have an object that performs work, which is decorated by a logging decorator, which in turn is decorated by a debugging decorator. Decorated objects can use wantarray(), but should not use caller() [yet].
To decorate a single method, or several methods with differing decorations, use the alternative \'methods\' constructor:
use Class::Decorator; my $object = Foo::Bar->new(); # the object to be decorated my $decorator = Class::Decorator->new( obj => $object, methods => { foobar => { pre => sub{print \"before foobar()\ \"}, post => sub{print \"after foobar()\ \"} } } ); $decorator->foobar(AATTargs); # decorated $decorator->barbaz(AATTargs); # not decorated
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl:/CPAN-C/openSUSE_Tumbleweed/noarch |