7 use if ( not our $__mx_is_compiled ), 'Moose::Meta::Class';
8 use if ( not our $__mx_is_compiled ), metaclass => 'Moose::Meta::Class';
10 our $VERSION = '0.70';
11 $VERSION = eval $VERSION;
12 our $AUTHORITY = 'cpan:STEVAN';
16 my $params = $class->BUILDARGS(@_);
17 my $self = $class->meta->new_object($params);
18 $self->BUILDALL($params);
26 (ref($_[0]) eq 'HASH')
27 || $class->meta->throw_error("Single parameters to new() must be a HASH ref", data => $_[0]);
31 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}->execute($self, $params);
52 # NOTE: we ask Perl if we even
53 # need to do this first, to avoid
54 # extra meta level calls
55 return unless $self->can('DEMOLISH');
56 foreach my $method ($self->meta->find_all_methods_by_name('DEMOLISH')) {
57 $method->{code}->execute($self);
62 # if we have an exception here ...
66 # run DEMOLISHALL ourselves, ...
71 # otherwise it is normal destruction
75 # support for UNIVERSAL::DOES ...
77 my $does = UNIVERSAL->can("DOES") ? "SUPER::DOES" : "isa";
79 my ( $self, $class_or_role_name ) = @_;
80 return $self->'.$does.'($class_or_role_name)
81 || $self->does($class_or_role_name);
85 # new does() methods will be created
86 # as appropiate see Moose::Meta::Role
88 my ($self, $role_name) = @_;
89 my $meta = $self->meta;
91 || $meta->throw_error("You much supply a role name to does()");
92 foreach my $class ($meta->class_precedence_list) {
93 my $m = $meta->initialize($class);
95 if $m->can('does_role') && $m->does_role($role_name);
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<DOES ($class_or_role_name)>
161 A Moose Role aware implementation of L<UNIVERSAL/DOES>.
163 C<DOES> is equivalent to C<isa> or C<does>.
165 =item B<dump ($maxdepth)>
167 C'mon, how many times have you written the following code while debugging:
172 It can get seriously annoying, so why not just use this.
178 All complex software has bugs lurking in it, and this module is no
179 exception. If you find a bug please either email me, or add the bug
184 Stevan Little E<lt>stevan@iinteractive.comE<gt>
186 =head1 COPYRIGHT AND LICENSE
188 Copyright 2006-2009 by Infinity Interactive, Inc.
190 L<http://www.iinteractive.com>
192 This library is free software; you can redistribute it and/or modify
193 it under the same terms as Perl itself.