New modules
[gitmo/Moose.git] / lib / Moose / Util.pm
1 package Moose::Util;
2
3 use Exporter qw/import/;
4 use Scalar::Util qw/blessed/;
5
6 use strict;
7 use warnings;
8
9 our $VERSION = '0.01';
10
11 our $AUTHORITY = 'cpan:BERLE';
12
13 our @EXPORT_OK = qw/can_role/;
14
15 sub can_role {
16   my ($class,$does) = @_;
17
18   return ((!ref $class && eval { $class->isa ('UNIVERSAL') }) || Scalar::Util::blessed ($class))
19     && $class->can ('does')
20     && $class->does ($does);
21 }
22
23 1;
24
25 __END__
26
27 =pod
28
29 =head1 NAME
30
31 Moose::Util - Moose utilities
32
33 =head1 SYNOPSIS
34
35   use Moose::Util qw/can_role/;
36
37   if (can_role ($object,'rolename')) {
38     print "The object can do rolename!\n";
39   }
40
41 =head1 FUNCTIONS
42
43 =over 4
44
45 =item can_role
46
47   can_role ($object,$rolename);
48
49 Returns true if $object can do the role $rolename.
50
51 =back
52
53 =head1 BUGS
54
55 All complex software has bugs lurking in it, and this module is no 
56 exception. If you find a bug please either email me, or add the bug
57 to cpan-RT.
58
59 =head1 AUTHOR
60
61 Anders Nor Berle E<lt>debolaz@gmail.comE<gt>
62
63 =head1 COPYRIGHT AND LICENSE
64
65 Copyright 2007 by Infinity Interactive, Inc.
66
67 L<http://www.iinteractive.com>
68
69 This library is free software; you can redistribute it and/or modify
70 it under the same terms as Perl itself. 
71
72 =cut
73