more-tweaks
[gitmo/Moose.git] / lib / Moose / Object.pm
CommitLineData
fcd84ca9 1
2package Moose::Object;
3
4use strict;
5use warnings;
bc1e29b5 6use metaclass 'Moose::Meta::Class' => (
7 ':attribute_metaclass' => 'Moose::Meta::Attribute'
8);
9
b6aed8b0 10our $VERSION = '0.02';
fcd84ca9 11
12sub new {
82168dbb 13 my ($class, %params) = @_;
c0e30cf5 14 my $self = $class->meta->new_object(%params);
15 $self->BUILDALL(%params);
16 return $self;
fcd84ca9 17}
18
c0e30cf5 19sub BUILDALL {
20 my ($self, %params) = @_;
21 foreach my $method ($self->meta->find_all_methods_by_name('BUILD')) {
5569c072 22 $method->{code}->($self, %params);
c0e30cf5 23 }
24}
25
26sub DEMOLISHALL {
27 my $self = shift;
28 foreach my $method ($self->meta->find_all_methods_by_name('DEMOLISH')) {
5569c072 29 $method->{code}->($self);
c0e30cf5 30 }
31}
32
33sub DESTROY { goto &DEMOLISHALL }
34
fcd84ca9 351;
36
37__END__
38
39=pod
40
41=head1 NAME
42
e522431d 43Moose::Object - The base object for Moose
fcd84ca9 44
e522431d 45=head1 SYNOPSIS
fcd84ca9 46
47=head1 DESCRIPTION
48
49=head1 METHODS
50
51=over 4
52
53=item B<meta>
54
55=item B<new>
56
e522431d 57This will create a new instance and call C<BUILDALL>.
58
c0e30cf5 59=item B<BUILDALL>
60
e522431d 61This will call every C<BUILD> method in the inheritance hierarchy.
62
c0e30cf5 63=item B<DEMOLISHALL>
64
e522431d 65This will call every C<DEMOLISH> method in the inheritance hierarchy.
66
b6aed8b0 67=item B<NEXT>
68
fcd84ca9 69=back
70
71=head1 BUGS
72
73All complex software has bugs lurking in it, and this module is no
74exception. If you find a bug please either email me, or add the bug
75to cpan-RT.
76
fcd84ca9 77=head1 AUTHOR
78
79Stevan Little E<lt>stevan@iinteractive.comE<gt>
80
81=head1 COPYRIGHT AND LICENSE
82
83Copyright 2006 by Infinity Interactive, Inc.
84
85L<http://www.iinteractive.com>
86
87This library is free software; you can redistribute it and/or modify
88it under the same terms as Perl itself.
89
90=cut