Commit | Line | Data |
fcd84ca9 |
1 | |
2 | package Moose::Object; |
3 | |
4 | use strict; |
5 | use warnings; |
bc1e29b5 |
6 | |
7 | use metaclass 'Moose::Meta::Class' => ( |
8 | ':attribute_metaclass' => 'Moose::Meta::Attribute' |
9 | ); |
10 | |
11 | our $VERSION = '0.01'; |
fcd84ca9 |
12 | |
13 | sub new { |
c0e30cf5 |
14 | my $class = shift; |
15 | my %params = @_; |
16 | my $self = $class->meta->new_object(%params); |
17 | $self->BUILDALL(%params); |
18 | return $self; |
fcd84ca9 |
19 | } |
20 | |
c0e30cf5 |
21 | sub BUILDALL { |
22 | my ($self, %params) = @_; |
23 | foreach my $method ($self->meta->find_all_methods_by_name('BUILD')) { |
24 | $method->{method}->($self, %params); |
25 | } |
26 | } |
27 | |
28 | sub DEMOLISHALL { |
29 | my $self = shift; |
30 | foreach my $method ($self->meta->find_all_methods_by_name('DEMOLISH')) { |
31 | $method->{method}->($self); |
32 | } |
33 | } |
34 | |
35 | sub DESTROY { goto &DEMOLISHALL } |
36 | |
fcd84ca9 |
37 | 1; |
38 | |
39 | __END__ |
40 | |
41 | =pod |
42 | |
43 | =head1 NAME |
44 | |
e522431d |
45 | Moose::Object - The base object for Moose |
fcd84ca9 |
46 | |
e522431d |
47 | =head1 SYNOPSIS |
fcd84ca9 |
48 | |
49 | =head1 DESCRIPTION |
50 | |
51 | =head1 METHODS |
52 | |
53 | =over 4 |
54 | |
55 | =item B<meta> |
56 | |
57 | =item B<new> |
58 | |
e522431d |
59 | This will create a new instance and call C<BUILDALL>. |
60 | |
c0e30cf5 |
61 | =item B<BUILDALL> |
62 | |
e522431d |
63 | This will call every C<BUILD> method in the inheritance hierarchy. |
64 | |
c0e30cf5 |
65 | =item B<DEMOLISHALL> |
66 | |
e522431d |
67 | This will call every C<DEMOLISH> method in the inheritance hierarchy. |
68 | |
fcd84ca9 |
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 | |
fcd84ca9 |
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 |