02 Dec 2016 20:48:00 UTC
- Distribution: Acme-Damn
- Module version: 0.08
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (1)
- Testers (2774 / 2 / 0)
- KwaliteeBus factor: 0
- 96.92% Coverage
- License: perl_5
- Perl: v5.6.0
- Download (9.02KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version++ed by:1 non-PAUSE user
- SEE ALSO
- COPYRIGHT AND LICENSE
Acme::Damn - 'Unbless' Perl objects.
use Acme::Damn; my $ref = ... some reference ... my $obj = bless $ref , 'Some::Class'; ... do something with your object ... $ref = damn $obj; # recover the original reference (unblessed) ... neither $ref nor $obj are Some::Class objects ...
Acme::Damn provides a single routine, damn(), which takes a blessed reference (a Perl object), and unblesses it, to return the original reference.
By default, Acme::Damn exports the method damn() into the current namespace. Aliases for damn() (see below) may be imported upon request.
- damn object
damn() accepts a single blessed reference as its argument, and returns that reference unblessed. If object is not a blessed reference, then damn() will
diewith an error.
- bless reference
- bless reference [ , package ]
- bless reference [ , undef ]
Optionally, Acme::Damn will modify the behaviour of
blessto allow the passing of an explicit
undefas the target package to invoke damn():
use Acme::Damn qw( bless ); my $obj = ... some blessed reference ...; # the following statements are equivalent my $ref = bless $obj , undef; my $ref = damn $obj;
NOTE: The modification of
blessis lexically scoped to the current package, and is not global.
Not everyone likes to damn the same way or in the same language, so Acme::Damn offers the ability to specify any alias on import, provided that alias is a valid Perl subroutine name (i.e. all characters match
use Acme::Damn qw( unbless ); use Acme::Damn qw( foo ); use Acme::Damn qw( unblessthyself ); use Acme::Damn qw( recant );
Version 0.02 supported a defined list of aliases, and this has been replaced in v0.03 by the ability to import any alias for
blessdoesn't call an object's initialisation code,
damndoesn't invoke an object's
DESTROYmethod. For objects that need to be
DESTROYed, either don't
damnthem, or call
DESTROYbefore judgement is passed.
Thanks to Claes Jacobsson <email@example.com> for suggesting the use of aliases, and Bo Lindbergh <firstname.lastname@example.org> for the suggested modification of
Ian Brayshaw, <email@example.com>
Copyright 2003-2016 Ian Brayshaw
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
|s||Focus search bar|
|?||Bring up this help dialog|
|g p||Go to pull requests|
|g i||go to github issues (only if github is preferred repository)|
|g a||Go to author|
|g c||Go to changes|
|g i||Go to issues|
|g d||Go to dist|
|g r||Go to repository/SCM|
|g s||Go to source|
|g b||Go to file browse|