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 (ref($_[0]) eq 'HASH')
29 || confess "Single parameters to new() must be a HASH ref";
33 return {}; # FIXME this is compat behavior, but is it correct?
40 # NOTE: we ask Perl if we even
41 # need to do this first, to avoid
42 # extra meta level calls
43 return unless $_[0]->can('BUILD');
44 my ($self, $params) = @_;
45 foreach my $method (reverse $self->meta->find_all_methods_by_name('BUILD')) {
46 $method->{code}->body->($self, $params);
52 foreach my $method ($self->meta->find_all_methods_by_name('DEMOLISH')) {
53 $method->{code}->body->($self);
58 # NOTE: we ask Perl if we even
59 # need to do this first, to avoid
60 # extra meta level calls
61 return unless $_[0]->can('DEMOLISH');
62 # if we have an exception here ...
66 # run DEMOLISHALL ourselves, ...
71 # otherwise it is normal destruction
75 # new does() methods will be created
76 # as approiate see Moose::Meta::Role
78 my ($self, $role_name) = @_;
80 || confess "You must supply a role name to does()";
81 my $meta = $self->meta;
82 foreach my $class ($meta->class_precedence_list) {
83 my $m = $meta->initialize($class);
85 if $m->can('does_role') && $m->does_role($role_name);
91 # Cmon, how many times have you written
92 # the following code while debugging:
95 # warn Dumper \%thing;
97 # It can get seriously annoying, so why
98 # not just do this ...
101 require Data::Dumper;
102 local $Data::Dumper::Maxdepth = shift if @_;
103 Data::Dumper::Dumper $self;
114 Moose::Object - The base object for Moose
118 This serves as the base object for all Moose classes. Every
119 effort will be made to ensure that all classes which C<use Moose>
120 will inherit from this class. It provides a default constructor
121 and destructor, which run all the BUILD and DEMOLISH methods in
124 You don't actually I<need> to inherit from this in order to
125 use Moose though. It is just here to make life easier.
133 This will return the metaclass associated with the given class.
137 This will call C<BUILDARGS>, create a new instance and call C<BUILDALL>.
141 This method processes an argument list into a hash reference. It is used by
146 This will call every C<BUILD> method in the inheritance hierarchy,
147 and pass it a hash-ref of the the C<%params> passed to C<new>.
151 This will call every C<DEMOLISH> method in the inheritance hierarchy.
153 =item B<does ($role_name)>
155 This will check if the invocant's class C<does> a given C<$role_name>.
156 This is similar to C<isa> for object, but it checks the roles instead.
158 =item B<dump ($maxdepth)>
160 Cmon, how many times have you written the following code while debugging:
165 It can get seriously annoying, so why not just use this.
171 All complex software has bugs lurking in it, and this module is no
172 exception. If you find a bug please either email me, or add the bug
177 Stevan Little E<lt>stevan@iinteractive.comE<gt>
179 =head1 COPYRIGHT AND LICENSE
181 Copyright 2006-2008 by Infinity Interactive, Inc.
183 L<http://www.iinteractive.com>
185 This library is free software; you can redistribute it and/or modify
186 it under the same terms as Perl itself.