Commit | Line | Data |
fcd84ca9 |
1 | |
2 | package Moose::Object; |
3 | |
4 | use strict; |
5 | use warnings; |
bc1e29b5 |
6 | use metaclass 'Moose::Meta::Class' => ( |
7 | ':attribute_metaclass' => 'Moose::Meta::Attribute' |
8 | ); |
9 | |
b6aed8b0 |
10 | use Carp 'confess'; |
11 | |
12 | our $VERSION = '0.02'; |
fcd84ca9 |
13 | |
14 | sub 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 |
22 | sub 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 | |
29 | sub 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 | |
36 | sub DESTROY { goto &DEMOLISHALL } |
37 | |
fcd84ca9 |
38 | 1; |
39 | |
40 | __END__ |
41 | |
42 | =pod |
43 | |
44 | =head1 NAME |
45 | |
e522431d |
46 | Moose::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 |
60 | This will create a new instance and call C<BUILDALL>. |
61 | |
c0e30cf5 |
62 | =item B<BUILDALL> |
63 | |
e522431d |
64 | This will call every C<BUILD> method in the inheritance hierarchy. |
65 | |
c0e30cf5 |
66 | =item B<DEMOLISHALL> |
67 | |
e522431d |
68 | This 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 | |
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 | |
fcd84ca9 |
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 |