refactor load_first_existing_class
[gitmo/Class-MOP.git] / lib / Class / MOP / Object.pm
CommitLineData
6e57504d 1
2package Class::MOP::Object;
3
4use strict;
5use warnings;
6
7use Scalar::Util 'blessed';
8
f6ca0704 9our $VERSION = '0.94';
d519662a 10$VERSION = eval $VERSION;
6e57504d 11our $AUTHORITY = 'cpan:STEVAN';
12
13# introspection
14
15sub meta {
16 require Class::MOP::Class;
17 Class::MOP::Class->initialize(blessed($_[0]) || $_[0]);
18}
19
4e99d48b 20sub _new {
6d49ce62 21 Class::MOP::class_of(shift)->new_object(@_);
4e99d48b 22}
23
c4260b45 24# RANT:
25# Cmon, how many times have you written
26# the following code while debugging:
27#
28# use Data::Dumper;
29# warn Dumper $obj;
30#
31# It can get seriously annoying, so why
32# not just do this ...
33sub dump {
34 my $self = shift;
35 require Data::Dumper;
acce7fd6 36 local $Data::Dumper::Maxdepth = shift || 1;
c4260b45 37 Data::Dumper::Dumper $self;
38}
39
6e57504d 401;
41
42__END__
43
44=pod
45
46=head1 NAME
47
d6c497d5 48Class::MOP::Object - Base class for metaclasses
6e57504d 49
50=head1 DESCRIPTION
51
d6c497d5 52This class is a very minimal base class for metaclasses.
53
6e57504d 54=head1 METHODS
55
d6c497d5 56This class provides a few methods which are useful in all metaclasses.
57
6e57504d 58=over 4
59
d6c497d5 60=item B<< Class::MOP::???->meta >>
61
62This returns a L<Class::MOP::Class> object.
6e57504d 63
d6c497d5 64=item B<< $metaobject->dump($max_depth) >>
c4260b45 65
d6c497d5 66This method uses L<Data::Dumper> to dump the object. You can pass an
67optional maximum depth, which will set C<$Data::Dumper::Maxdepth>. The
68default maximum depth is 1.
88dd563c 69
6e57504d 70=back
71
72=head1 AUTHORS
73
74Stevan Little E<lt>stevan@iinteractive.comE<gt>
75
76=head1 COPYRIGHT AND LICENSE
77
070bb6c9 78Copyright 2006-2009 by Infinity Interactive, Inc.
6e57504d 79
80L<http://www.iinteractive.com>
81
82This library is free software; you can redistribute it and/or modify
83it under the same terms as Perl itself.
84
88dd563c 85=cut