7 use if ( not our $__mx_is_compiled ), 'Moose::Meta::Class';
8 use if ( not our $__mx_is_compiled ), metaclass => 'Moose::Meta::Class';
12 our $VERSION = '0.13';
13 our $AUTHORITY = 'cpan:STEVAN';
20 (ref($_[0]) eq 'HASH')
21 || confess "Single parameters to new() must be a HASH ref";
28 my $self = $class->meta->new_object(%params);
29 $self->BUILDALL(\%params);
34 # NOTE: we ask Perl if we even
35 # need to do this first, to avoid
36 # extra meta level calls
37 return unless $_[0]->can('BUILD');
38 my ($self, $params) = @_;
39 foreach my $method (reverse $self->meta->find_all_methods_by_name('BUILD')) {
40 $method->{code}->body->($self, $params);
46 foreach my $method ($self->meta->find_all_methods_by_name('DEMOLISH')) {
47 $method->{code}->body->($self);
52 # NOTE: we ask Perl if we even
53 # need to do this first, to avoid
54 # extra meta level calls
55 return unless $_[0]->can('DEMOLISH');
56 # if we have an exception here ...
58 # run DEMOLISHALL ourselves, ...
60 # then restore the exception ...
68 # new does() methods will be created
69 # as approiate see Moose::Meta::Role
71 my ($self, $role_name) = @_;
73 || confess "You much supply a role name to does()";
74 my $meta = $self->meta;
75 foreach my $class ($meta->class_precedence_list) {
76 my $m = $meta->initialize($class);
78 if $m->can('does_role') && $m->does_role($role_name);
84 # Cmon, how many times have you written
85 # the following code while debugging:
88 # warn Dumper \%thing;
90 # It can get seriously annoying, so why
91 # not just do this ...
95 local $Data::Dumper::Maxdepth = shift if @_;
96 Data::Dumper::Dumper $self;
107 Moose::Object - The base object for Moose
111 This serves as the base object for all Moose classes. Every
112 effort will be made to ensure that all classes which C<use Moose>
113 will inherit from this class. It provides a default constructor
114 and destructor, which run all the BUILD and DEMOLISH methods in
117 You don't actually I<need> to inherit from this in order to
118 use Moose though. It is just here to make life easier.
126 This will return the metaclass associated with the given class.
130 This will create a new instance and call C<BUILDALL>.
134 This will call every C<BUILD> method in the inheritance hierarchy,
135 and pass it a hash-ref of the the C<%params> passed to C<new>.
139 This will call every C<DEMOLISH> method in the inheritance hierarchy.
141 =item B<does ($role_name)>
143 This will check if the invocant's class C<does> a given C<$role_name>.
144 This is similar to C<isa> for object, but it checks the roles instead.
146 =item B<dump ($maxdepth)>
148 Cmon, how many times have you written the following code while debugging:
153 It can get seriously annoying, so why not just use this.
159 All complex software has bugs lurking in it, and this module is no
160 exception. If you find a bug please either email me, or add the bug
165 Stevan Little E<lt>stevan@iinteractive.comE<gt>
167 =head1 COPYRIGHT AND LICENSE
169 Copyright 2006-2008 by Infinity Interactive, Inc.
171 L<http://www.iinteractive.com>
173 This library is free software; you can redistribute it and/or modify
174 it under the same terms as Perl itself.