7 use Moose::Meta::Class;
8 use metaclass 'Moose::Meta::Class' => (
9 ':attribute_metaclass' => 'Moose::Meta::Attribute'
14 our $VERSION = '0.04';
18 my %params = (scalar @_ == 1) ? %{$_[0]} : @_;
19 my $self = $class->meta->new_object(%params);
20 $self->BUILDALL(\%params);
25 my ($self, $params) = @_;
26 foreach my $method (reverse $self->meta->find_all_methods_by_name('BUILD')) {
27 $method->{code}->($self, $params);
33 foreach my $method ($self->meta->find_all_methods_by_name('DEMOLISH')) {
34 $method->{code}->($self);
38 sub DESTROY { goto &DEMOLISHALL }
40 # new does() methods will be created
41 # as approiate see Moose::Meta::Role
43 my ($self, $role_name) = @_;
45 || confess "You much supply a role name to does()";
46 my $meta = $self->meta;
47 foreach my $class ($meta->class_precedence_list) {
49 if $meta->initialize($class)->does_role($role_name);
62 Moose::Object - The base object for Moose
66 This serves as the base object for all Moose classes. Every
67 effort will be made to ensure that all classes which C<use Moose>
68 will inherit from this class. It provides a default constructor
69 and destructor, which run all the BUILD and DEMOLISH methods in
72 You don't actually I<need> to inherit from this in order to
73 use Moose though. It is just here to make life easier.
81 This will return the metaclass associated with the given class.
85 This will create a new instance and call C<BUILDALL>.
89 This will call every C<BUILD> method in the inheritance hierarchy,
90 and pass it a hash-ref of the the C<%params> passed to C<new>.
94 This will call every C<DEMOLISH> method in the inheritance hierarchy.
96 =item B<does ($role_name)>
102 All complex software has bugs lurking in it, and this module is no
103 exception. If you find a bug please either email me, or add the bug
108 Stevan Little E<lt>stevan@iinteractive.comE<gt>
110 =head1 COPYRIGHT AND LICENSE
112 Copyright 2006 by Infinity Interactive, Inc.
114 L<http://www.iinteractive.com>
116 This library is free software; you can redistribute it and/or modify
117 it under the same terms as Perl itself.