GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Object::AUTHORITY(3) User Contributed Perl Documentation Object::AUTHORITY(3)

Object::AUTHORITY - adds an AUTHORITY method to your class

 {
   package MyClass;
   use Object::AUTHORITY;
   BEGIN {
     $MyClass::AUTHORITY = 'cpan:TOBYINK';
     $MyClass::VERSION   = '0.001';
   }
 }
 
 print MyClass->AUTHORITY . "\n";   # prints "cpan:TOBYINK\n";
 MyClass->AUTHORITY('cpan:FOO');    # assertion fails, croaks.

This module adds an "AUTHORITY" function to your package, which works along the same lines as the "VERSION" function.

The authority of a package can be defined like this:

 package MyApp;
 BEGIN { $MyApp::AUTHORITY = 'cpan:JOEBLOGGS'; }

The authority should be a URI identifying the person, team, organisation or trained chimp responsible for the release of the package. The pseudo-URI scheme "cpan:" is the most commonly used identifier.

Called with no parameters returns the authority of the module.

If passed a test, will croak if the test fails. The authority is tested against the test using something approximating Perl 5.10's smart match operator. (Briefly, you can pass a string for "eq" comparison, a regular expression, a code reference to use as a callback, or an array reference that will be grepped.)

"Object::AUTHORITY::reasonably_smart_match($a, $b)"
Object::AUTHORITY exposes its smart match implementation in case classes wish to reuse it for their own custom "AUTHORITY" methods. (There are various interesting use cases for custom "AUTHORITY" methods, just as there are for custom "can" and "isa" methods.)

The $a parameter is always assumed to be a simple scalar.

Please report any bugs to <http://rt.cpan.org/Dist/Display.html?Queue=Object-AUTHORITY>.

  • Object::AUTHORITY (this module) - an AUTHORITY method for your class
  • authority::shared - a more sophisticated AUTHORITY method for your class
  • UNIVERSAL::AUTHORITY - an AUTHORITY method for every class (deprecated)
  • UNIVERSAL::AUTHORITY::Lexical - an AUTHORITY method for every class, within a lexical scope
  • authority - load modules only if they have a particular authority

Background reading: <http://feather.perl6.nl/syn/S11.html>, <http://www.perlmonks.org/?node_id=694377>.

Toby Inkster <tobyink@cpan.org>.

This software is copyright (c) 2011 by Toby Inkster.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
2011-12-15 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.