Toby Inkster avatar Toby Inkster committed 51e9651

Deprecate this module.

Comments (0)

Files changed (2)

lib/UNIVERSAL/AUTHORITY.pm

 package UNIVERSAL::AUTHORITY;
-
-use 5.005;
+use 5.006;
 use strict;
-
 BEGIN {
 	$UNIVERSAL::AUTHORITY::AUTHORITY = 'cpan:TOBYINK';
-	$UNIVERSAL::AUTHORITY::VERSION   = '0.002';
+	$UNIVERSAL::AUTHORITY::VERSION   = '0.003';
 }
-
-use Carp qw[croak];
-use Scalar::Util qw[blessed];
-use UNIVERSAL qw[];
-
-sub UNIVERSAL::AUTHORITY
-{
-	my ($invocant, $test) = @_;
-	$invocant = ref $invocant if blessed($invocant);
-	
-	my $authority = do {
-		no strict 'refs';
-		${"$invocant\::AUTHORITY"};
-		};
-	
-	if (scalar @_ > 1)
-	{
-		if (defined $authority)
-		{
-			croak("Invocant ($invocant) has authority '$authority'")
-				unless reasonably_smart_match($authority, $test);
-		}
-		else
-		{
-			croak("Invocant ($invocant) has no authority defined")
-				unless reasonably_smart_match($authority, $test);
-		}
-	}
-	
-	return $authority;
-}
-
-sub reasonably_smart_match
-{
-	my ($a, $b) = @_;
-	
-	if (!defined $b)
-	{
-		return !defined $a;
-	}
-	elsif (ref $b eq 'CODE')
-	{
-		return $b->($a);
-	}
-	elsif (ref $b eq 'HASH')
-	{
-		return unless defined $a;
-		return exists $b->{$a};
-	}
-	elsif (ref $b eq 'ARRAY')
-	{
-		return grep { reasonably_smart_match($a, $_) } @$b;
-	}
-	elsif (ref $b eq 'Regexp')
-	{
-		return ($a =~ $b);
-	}
-	else
-	{
-		return ($a eq $b);
-	}
-}
-
+use Object::AUTHORITY -package => 'UNIVERSAL';
+*reasonably_smart_match = \&Object::AUTHORITY::reasonably_smart_match;
 1;
 
 __END__
 
 =head1 DESCRIPTION
 
+B<This module is deprecated:> use L<UNIVERSAL::AUTHORITY::Lexical> instead.
+
 This module adds an C<AUTHORITY> function to the C<UNIVERSAL> package, which
 works along the same lines as the C<VERSION> function. Because it is defined
 in C<UNIVERSAL>, it becomes instantly available as a method for any blessed
 expression, a code reference to use as a callback, or an array reference
 that will be grepped.)
 
-=head2 Utility Function
+=begin private
 
-=over
+=head2 reasonably_smart_match($scalar, $test)
 
-=item C<< UNIVERSAL::AUTHORITY::reasonably_smart_match($a, $b) >>
-
-UNIVERSAL::AUTHORITY exposes its smart match implementation in case
-classes wish to reuse it for their own custom C<AUTHORITY> methods. (There
-are various interesting use cases for custom C<AUTHORITY> methods, just as
-there are for custom C<can> and C<isa> methods.)
-
-The C<< $a >> parameter is assumed to be a scalar.
-
-=back
+=end private
 
 =head1 BUGS
 
 
 =head1 SEE ALSO
 
-L<authority>,
-L<authority::shared>,
-L<http://feather.perl6.nl/syn/S11.html>,
+=over
+
+=item * L<Object::AUTHORITY> - an AUTHORITY method for your class
+
+=item * L<authority::shared> - a more sophisticated AUTHORITY method for your class
+
+=item * I<UNIVERSAL::AUTHORITY> (this module) - an AUTHORITY method for every class (deprecated)
+
+=item * L<UNIVERSAL::AUTHORITY::Lexical> - an AUTHORITY method for every class, within a lexical scope
+
+=item * L<authority> - load modules only if they have a particular authority
+
+=back
+
+Background reading: L<http://feather.perl6.nl/syn/S11.html>,
 L<http://www.perlmonks.org/?node_id=694377>.
 
-L<UNIVERSAL>,
-L<UNIVERSAL::which>,
-L<UNIVERSAL::dump>,
-L<UNIVERSAL::DOES>,
-&c.
-
 =head1 AUTHOR
 
 Toby Inkster E<lt>tobyink@cpan.orgE<gt>.
 		dcs:item   [ rdfs:label "Allow calling as an object method."@en ] ;
 		dcs:item   [ rdfs:label "Expose reaonably_smart_match utility function."@en ] ;
 		dcs:item   [ rdfs:label "Remove trailing full stops from croak messages."@en ]
+		] .
+
+dist:project :release dist:v_0-003 .
+dist:v_0-003
+	a               :Version ;
+	dc:issued       "2011-12-01"^^xsd:date ;
+	:revision       "0.003"^^xsd:string ;
+	:file-release   <http://backpan.cpan.org/authors/id/T/TO/TOBYINK/UNIVERSAL-AUTHORITY-0.003.tar.gz> ;
+	dcs:changeset [
+		dcs:versus dist:v_0-002 ;
+		dcs:item   [ rdfs:label "Deprecate this module."@en ] ;
+		dcs:item   [ rdfs:label "Reimplement using Object::AUTHORITY."@en ]
 		] .
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.