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.50';
13 our $AUTHORITY = 'cpan:STEVAN';
17 my $params = $class->BUILDARGS(@_);
18 my $self = $class->meta->new_object(%$params);
19 $self->BUILDALL($params);
28 no warnings 'uninitialized';
29 (ref($_[0]) eq 'HASH')
30 || confess "Single parameters to new() must be a HASH ref";
33 return {}; # FIXME this is compat behavior, but is it correct?
41 # NOTE: we ask Perl if we even
42 # need to do this first, to avoid
43 # extra meta level calls
44 return unless $_[0]->can('BUILD');
45 my ($self, $params) = @_;
46 foreach my $method (reverse $self->meta->find_all_methods_by_name('BUILD')) {
47 $method->{code}->body->($self, $params);
53 foreach my $method ($self->meta->find_all_methods_by_name('DEMOLISH')) {
54 $method->{code}->body->($self);
59 # NOTE: we ask Perl if we even
60 # need to do this first, to avoid
61 # extra meta level calls
62 return unless $_[0]->can('DEMOLISH');
63 # if we have an exception here ...
67 # run DEMOLISHALL ourselves, ...
72 # otherwise it is normal destruction
76 # new does() methods will be created
77 # as approiate see Moose::Meta::Role
79 my ($self, $role_name) = @_;
81 || confess "You must supply a role name to does()";
82 my $meta = $self->meta;
83 foreach my $class ($meta->class_precedence_list) {
84 my $m = $meta->initialize($class);
86 if $m->can('does_role') && $m->does_role($role_name);
92 # Cmon, how many times have you written
93 # the following code while debugging:
96 # warn Dumper \%thing;
98 # It can get seriously annoying, so why
99 # not just do this ...
102 require Data::Dumper;
103 local $Data::Dumper::Maxdepth = shift if @_;
104 Data::Dumper::Dumper $self;
115 Moose::Object - The base object for Moose
119 This serves as the base object for all Moose classes. Every
120 effort will be made to ensure that all classes which C<use Moose>
121 will inherit from this class. It provides a default constructor
122 and destructor, which run all the BUILD and DEMOLISH methods in
125 You don't actually I<need> to inherit from this in order to
126 use Moose though. It is just here to make life easier.
134 This will return the metaclass associated with the given class.
138 This will call C<BUILDARGS>, create a new instance and call C<BUILDALL>.
142 This method processes an argument list into a hash reference. It is used by
147 This will call every C<BUILD> method in the inheritance hierarchy,
148 and pass it a hash-ref of the the C<%params> passed to C<new>.
152 This will call every C<DEMOLISH> method in the inheritance hierarchy.
154 =item B<does ($role_name)>
156 This will check if the invocant's class C<does> a given C<$role_name>.
157 This is similar to C<isa> for object, but it checks the roles instead.
159 =item B<dump ($maxdepth)>
161 Cmon, how many times have you written the following code while debugging:
166 It can get seriously annoying, so why not just use this.
172 All complex software has bugs lurking in it, and this module is no
173 exception. If you find a bug please either email me, or add the bug
178 Stevan Little E<lt>stevan@iinteractive.comE<gt>
180 =head1 COPYRIGHT AND LICENSE
182 Copyright 2006-2008 by Infinity Interactive, Inc.
184 L<http://www.iinteractive.com>
186 This library is free software; you can redistribute it and/or modify
187 it under the same terms as Perl itself.