|
NAMEnamespace::sweep - Sweep up imported subs in your classesVERSIONversion 0.006SYNOPSISpackage Foo; use namespace::sweep; use Some::Module qw(some_function); sub my_method { my $foo = some_function(); ... } package main; Foo->my_method; # ok Foo->some_function; # ERROR! DESCRIPTIONBecause Perl methods are just regular subroutines, it's difficult to tell what's a method and what's just an imported function. As a result, imported functions can be called as methods on your objects. This pragma will delete imported functions from your class's symbol table, thereby ensuring that your interface is as you specified it. However, code inside your module will still be able to use the imported functions without any problems.ARGUMENTSThe following arguments may be passed on the "use" line:
RATIONALEThis pragma was written to address some problems with the excellent namespace::autoclean. In particular, namespace::autoclean will remove special symbols that are installed by overload, so you can't use namespace::autoclean on objects that overload Perl operators.Additionally, namespace::autoclean relies on Class::MOP to figure out the list of methods provided by your class. This pragma does not depend on Class::MOP or Moose, so you can use it for non-Moose classes without worrying about heavy dependencies. However, if your class has a Moose (or Moose-compatible) "meta" object, then that will be used to find e.g. methods from composed roles that should not be deleted. In most cases, namespace::sweep should work as a drop-in replacement for namespace::autoclean. Upon release, this pragma passes all of namespace::autoclean's tests, in addition to its own. CAVEATSThis is an early release and there are bound to be a few hiccups along the way.ACKNOWLEDGEMENTSThanks Florian Ragwitz and Tomas Doran for writing and maintaining namespace::autoclean.Thanks to Toby Inkster for submitting some better code for finding "meta" objects. SEE ALSOnamespace::autoclean, namespace::clean, overloadAUTHORMike Friedman <friedo@friedo.com>COPYRIGHT AND LICENSEThis software is copyright (c) 2011 by Mike Friedman.This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Visit the GSP FreeBSD Man Page Interface. |