7 use Moose::Meta::Class;
8 use metaclass 'Moose::Meta::Class';
12 our $VERSION = '0.05';
16 my %params = (scalar @_ == 1) ? %{$_[0]} : @_;
17 my $self = $class->meta->new_object(%params);
18 $self->BUILDALL(\%params);
23 my ($self, $params) = @_;
24 foreach my $method (reverse $self->meta->find_all_methods_by_name('BUILD')) {
25 $method->{code}->($self, $params);
31 foreach my $method ($self->meta->find_all_methods_by_name('DEMOLISH')) {
32 $method->{code}->($self);
36 sub DESTROY { goto &DEMOLISHALL }
38 # new does() methods will be created
39 # as approiate see Moose::Meta::Role
41 my ($self, $role_name) = @_;
43 || confess "You much supply a role name to does()";
44 my $meta = $self->meta;
45 foreach my $class ($meta->class_precedence_list) {
47 if $meta->initialize($class)->does_role($role_name);
60 Moose::Object - The base object for Moose
64 This serves as the base object for all Moose classes. Every
65 effort will be made to ensure that all classes which C<use Moose>
66 will inherit from this class. It provides a default constructor
67 and destructor, which run all the BUILD and DEMOLISH methods in
70 You don't actually I<need> to inherit from this in order to
71 use Moose though. It is just here to make life easier.
79 This will return the metaclass associated with the given class.
83 This will create a new instance and call C<BUILDALL>.
87 This will call every C<BUILD> method in the inheritance hierarchy,
88 and pass it a hash-ref of the the C<%params> passed to C<new>.
92 This will call every C<DEMOLISH> method in the inheritance hierarchy.
94 =item B<does ($role_name)>
96 This will check if the invocant's class C<does> a given C<$role_name>.
97 This is similar to C<isa> for object, but it checks the roles instead.
103 All complex software has bugs lurking in it, and this module is no
104 exception. If you find a bug please either email me, or add the bug
109 Stevan Little E<lt>stevan@iinteractive.comE<gt>
111 =head1 COPYRIGHT AND LICENSE
113 Copyright 2006 by Infinity Interactive, Inc.
115 L<http://www.iinteractive.com>
117 This library is free software; you can redistribute it and/or modify
118 it under the same terms as Perl itself.