Object::AUTHORITY(3pm)

Object::AUTHORITY3pm

Adds an authority method to your class

Usage

 {
   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.

Overview

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.

"authority"

Called with no parameters returns the authority of the module.

"AUTHORITY($test)"

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.)

Utility Function

"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.

Disclaimer of warranties

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.

Bugs

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

Author

Toby Inkster <[email protected]>.

From libobject-authority-perl 0.004-1 in Debian 7 (Wheezy). Parsed by carta from the page's man source.