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 | |
505c6fac |
35 | sub NEXT { |
36 | my $self = shift; |
37 | my $method = (caller())[3]; |
38 | my $code = $self->meta->find_next_method_by_name($method); |
39 | (defined $code) |
40 | || confess "Could not find the NEXT method for ($method) in ($self)"; |
41 | return $code->($self, @_); |
42 | } |
43 | |
c0e30cf5 |
44 | sub DESTROY { goto &DEMOLISHALL } |
45 | |
fcd84ca9 |
46 | 1; |
47 | |
48 | __END__ |
49 | |
50 | =pod |
51 | |
52 | =head1 NAME |
53 | |
e522431d |
54 | Moose::Object - The base object for Moose |
fcd84ca9 |
55 | |
e522431d |
56 | =head1 SYNOPSIS |
fcd84ca9 |
57 | |
58 | =head1 DESCRIPTION |
59 | |
60 | =head1 METHODS |
61 | |
62 | =over 4 |
63 | |
64 | =item B<meta> |
65 | |
66 | =item B<new> |
67 | |
e522431d |
68 | This will create a new instance and call C<BUILDALL>. |
69 | |
c0e30cf5 |
70 | =item B<BUILDALL> |
71 | |
e522431d |
72 | This will call every C<BUILD> method in the inheritance hierarchy. |
73 | |
c0e30cf5 |
74 | =item B<DEMOLISHALL> |
75 | |
e522431d |
76 | This will call every C<DEMOLISH> method in the inheritance hierarchy. |
77 | |
fcd84ca9 |
78 | =back |
79 | |
80 | =head1 BUGS |
81 | |
82 | All complex software has bugs lurking in it, and this module is no |
83 | exception. If you find a bug please either email me, or add the bug |
84 | to cpan-RT. |
85 | |
fcd84ca9 |
86 | =head1 AUTHOR |
87 | |
88 | Stevan Little E<lt>stevan@iinteractive.comE<gt> |
89 | |
90 | =head1 COPYRIGHT AND LICENSE |
91 | |
92 | Copyright 2006 by Infinity Interactive, Inc. |
93 | |
94 | L<http://www.iinteractive.com> |
95 | |
96 | This library is free software; you can redistribute it and/or modify |
97 | it under the same terms as Perl itself. |
98 | |
99 | =cut |