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