7 use Moose::Meta::Class;
8 use metaclass 'Moose::Meta::Class';
12 our $VERSION = '0.07';
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 return unless $_[0]->can('BUILD');
32 my ($self, $params) = @_;
33 foreach my $method (reverse $self->meta->find_all_methods_by_name('BUILD')) {
34 $method->{code}->($self, $params);
39 return unless $_[0]->can('DEMOLISH');
41 foreach my $method ($self->meta->find_all_methods_by_name('DEMOLISH')) {
42 $method->{code}->($self);
46 sub DESTROY { goto &DEMOLISHALL }
48 # new does() methods will be created
49 # as approiate see Moose::Meta::Role
51 my ($self, $role_name) = @_;
53 || confess "You much supply a role name to does()";
54 my $meta = $self->meta;
55 foreach my $class ($meta->class_precedence_list) {
57 if $meta->initialize($class)->does_role($role_name);
63 # Cmon, how many times have you written
64 # the following code while debugging:
67 # warn Dumper \%thing;
69 # It can get seriously annoying, so why
70 # not just do this ...
74 $Data::Dumper::Maxdepth = shift if @_;
75 Data::Dumper::Dumper $self;
86 Moose::Object - The base object for Moose
90 This serves as the base object for all Moose classes. Every
91 effort will be made to ensure that all classes which C<use Moose>
92 will inherit from this class. It provides a default constructor
93 and destructor, which run all the BUILD and DEMOLISH methods in
96 You don't actually I<need> to inherit from this in order to
97 use Moose though. It is just here to make life easier.
105 This will return the metaclass associated with the given class.
109 This will create a new instance and call C<BUILDALL>.
113 This will call every C<BUILD> method in the inheritance hierarchy,
114 and pass it a hash-ref of the the C<%params> passed to C<new>.
118 This will call every C<DEMOLISH> method in the inheritance hierarchy.
120 =item B<does ($role_name)>
122 This will check if the invocant's class C<does> a given C<$role_name>.
123 This is similar to C<isa> for object, but it checks the roles instead.
125 =item B<dump ($maxdepth)>
127 Cmon, how many times have you written the following code while debugging:
132 It can get seriously annoying, so why not just use this.
138 All complex software has bugs lurking in it, and this module is no
139 exception. If you find a bug please either email me, or add the bug
144 Stevan Little E<lt>stevan@iinteractive.comE<gt>
146 =head1 COPYRIGHT AND LICENSE
148 Copyright 2006 by Infinity Interactive, Inc.
150 L<http://www.iinteractive.com>
152 This library is free software; you can redistribute it and/or modify
153 it under the same terms as Perl itself.