NAME
Class::Maker::Examples::Obsessor - methodcall dispatcher/forwarder
SYNOPSIS
use Class::Maker::Examples::Obsessor;
use Verify;
use Class::Maker::Examples::User;
# binding to a class (a clean object is created)
{
my $user = Class::Maker::Examples::Obsessor->new( target => 'User' );
$user->email( 'murat.uenalan@gmx.de' );
$user->firstname( 'Murat' );
$user->lastname( 'Murat' );
#$user->blabla();
print Dumper $user;
}
# binding to existing object
{
my $user = Class::Maker::Examples::Obsessor->new( target => new User( firstname => 'Murat', lastname => 'Uenalan' ) );
$user->email( 'murat.uenalan@gmx.de' );
$user->firstname( 'Murat' );
#$user->blabla();
print Dumper $user;
}
package Verify::Type;
our $positivliste = new Verify::Type(
desc => 'test access right',
pass => { exists_in => { firstname => 1, lastname => 1, email => 1 } },
fail => { exists_in => [qw(blabla)] }
);
package main;
{
my $accesstester = new Class::Maker::Examples::Bouncer( );
push @{ $accesstester->tests }, new Class::Maker::Examples::Bouncer::Test( field => 'method', type => 'positivliste' );
my $user = Class::Maker::Examples::Obsessor->new();
# CAVE: target is an Class::Maker::Examples::Obsessor method (the only one)
$user->Class::Maker::Examples::Obsessor::target( new User( firstname => 'Murat', lastname => 'Uenalan' ) );
push @{ $user->bouncers }, $accesstester;
# bouncer won't reject email, firstname or lastname, because they're in the pass-list
$user->email( 'murat.uenalan@gmx.de' );
$user->firstname( 'Murat' );
$user->lastname( 'Murat' );
# bouncer rejects 'blabla' because it's in fail-list
$user->blabla();
print Dumper $user;
}
DESCRIPTION
Class::Maker::Examples::Obsessor has nothing to do with a http-server. But, in the very principle it behaves like it. It serves a target class/object and has all might about it. This can be used i.e. to restrict/log/bench/forward/obscure/cache/.. the access to the target. After you plug a target to an Class::Maker::Examples::Obsessor, the resulting object behaves like the original target in terms of methodcalls. But a ref()-call would reveal the object beeing an Class::Maker::Examples::Obsessor in real. Also caller() would be influenced (unfortunately).
EXPORT
None by default.
EXAMPLE "Access restriction"
AUTHOR
Murat Ünalan, murat.uenalan@gmx.de
SEE ALSO
perl(1).
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 222:
Non-ASCII character seen before =encoding in 'Ünalan,'. Assuming CP1252