Object::Capsule - wrap any object in a flavorless capsule (don't use this)
use Object::Capsule; use Widget; my $widget = new Widget; my $capsule = encapsulate($widget); $capsule->some_widget_method; # performs method on widget print ref $capsule; # prints "Object::Capsule" print ref $$capsule; # prints "Widget"
Achtung!: This code is stupid. I wrote it to abuse Class::DBI. You probably shouldn't use it.
An Object::Capsule is a thin, permeable membrane that fits nicely around an object. Method calls are passed on to the object, which functions normally inside the capsule. The object can be retrieved by dereferencing the capsule as a scalar.
My intent is to use an object capsule subclass to allow the inflation of multiple object types from a single column in Class::DBI.
$capsule = encapsulate($object);
This function encases the given object in an Object::Capsule and returns the capsule. It's exported by default and is otherwise non-existent.
Please report any bugs or feature requests to
email@example.com, or through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
The proxy overloading code is hideous. The "future" version in the code had bizarre problems that I couldn't quite solve, but I'll try again sometime.
Ricardo SIGNES <firstname.lastname@example.org>
This software is copyright (c) 2004 by Ricardo SIGNES.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.