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