7 use Moose::Meta::Class;
8 use metaclass 'Moose::Meta::Class';
12 our $VERSION = '0.06';
18 (ref($_[0]) eq 'HASH')
19 || confess "Single parameters to new() must be a HASH ref";
25 my $self = $class->meta->new_object(%params);
26 $self->BUILDALL(\%params);
31 my ($self, $params) = @_;
32 foreach my $method (reverse $self->meta->find_all_methods_by_name('BUILD')) {
33 $method->{code}->($self, $params);
39 foreach my $method ($self->meta->find_all_methods_by_name('DEMOLISH')) {
40 $method->{code}->($self);
44 sub DESTROY { goto &DEMOLISHALL }
46 # new does() methods will be created
47 # as approiate see Moose::Meta::Role
49 my ($self, $role_name) = @_;
51 || confess "You much supply a role name to does()";
52 my $meta = $self->meta;
53 foreach my $class ($meta->class_precedence_list) {
55 if $meta->initialize($class)->does_role($role_name);
61 # Cmon, how many times have you written
62 # the following code while debugging:
65 # warn Dumper \%thing;
67 # It can get seriously annoying, so why
68 # not just do this ...
72 $Data::Dumper::Maxdepth = shift if @_;
73 Data::Dumper::Dumper $self;
84 Moose::Object - The base object for Moose
88 This serves as the base object for all Moose classes. Every
89 effort will be made to ensure that all classes which C<use Moose>
90 will inherit from this class. It provides a default constructor
91 and destructor, which run all the BUILD and DEMOLISH methods in
94 You don't actually I<need> to inherit from this in order to
95 use Moose though. It is just here to make life easier.
103 This will return the metaclass associated with the given class.
107 This will create a new instance and call C<BUILDALL>.
111 This will call every C<BUILD> method in the inheritance hierarchy,
112 and pass it a hash-ref of the the C<%params> passed to C<new>.
116 This will call every C<DEMOLISH> method in the inheritance hierarchy.
118 =item B<does ($role_name)>
120 This will check if the invocant's class C<does> a given C<$role_name>.
121 This is similar to C<isa> for object, but it checks the roles instead.
123 =item B<dump ($maxdepth)>
125 Cmon, how many times have you written the following code while debugging:
130 It can get seriously annoying, so why not just use this.
136 All complex software has bugs lurking in it, and this module is no
137 exception. If you find a bug please either email me, or add the bug
142 Stevan Little E<lt>stevan@iinteractive.comE<gt>
144 =head1 COPYRIGHT AND LICENSE
146 Copyright 2006 by Infinity Interactive, Inc.
148 L<http://www.iinteractive.com>
150 This library is free software; you can redistribute it and/or modify
151 it under the same terms as Perl itself.