Mouse::Util::does_role() respects $thing->does() method
[gitmo/Mouse.git] / lib / Mouse / Object.pm
1 package Mouse::Object;
2 use Mouse::Util qw(does dump meta); # enables strict and warnings
3 # all the stuff are defined in XS or PP
4
5 sub DOES {
6     my($self, $class_or_role_name) = @_;
7     return $self->isa($class_or_role_name) || $self->does($class_or_role_name);
8 }
9
10 1;
11 __END__
12
13 =head1 NAME
14
15 Mouse::Object - The base object for Mouse classes
16
17 =head1 VERSION
18
19 This document describes Mouse version 0.95
20
21 =head1 METHODS
22
23 =head2 C<< $class->new(%args | \%args) -> Object >>
24
25 Instantiates a new C<Mouse::Object>. This is obviously intended for subclasses.
26
27 =head2 C<< $class->BUILDARGS(@args) -> HashRef >>
28
29 Lets you override the arguments that C<new> takes.
30 It must return a HashRef of parameters.
31
32 =head2 C<< $object->BUILDALL(\%args) >>
33
34 Calls C<BUILD> on each class in the class hierarchy. This is called at the
35 end of C<new>.
36
37 =head2 C<< $object->BUILD(\%args) >>
38
39 You may put any business logic initialization in BUILD methods. You don't
40 need to redispatch or return any specific value.
41
42 =head2 C<< $object->DEMOLISHALL >>
43
44 Calls C<DEMOLISH> on each class in the class hierarchy. This is called at
45 C<DESTROY> time.
46
47 =head2 C<< $object->DEMOLISH >>
48
49 You may put any business logic deinitialization in DEMOLISH methods. You don't
50 need to redispatch or return any specific value.
51
52 =head2 C<< $object->does($role_name) -> Bool >>
53
54 This will check if the invocant's class B<does> a given C<$role_name>.
55 This is similar to C<isa> for object, but it checks the roles instead.
56
57 =head2 C<< $object->dump($maxdepth) -> Str >>
58
59 This is a handy utility for dumping an object with Data::Dumper.
60 By default, the maximum depth is 3, to avoid making a mess.
61
62 =head2 C<< $object->meta() -> MetaClass >>
63
64 This is a method which provides access to the object's metaclass.
65
66 =head1 SEE ALSO
67
68 L<Moose::Object>
69
70 =cut
71