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