X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FObject.pm;h=2117e0e95abb620b714f4cc268ace9f4f5a2dcc7;hb=6bf30233976676ca157c80174a7e73f0561dca4c;hp=6835bd27d0d01a0656f63ed2d39126fd6ba719b2;hpb=fcd84ca90cb39d34c25a5731fecb919b19c46afa;p=gitmo%2FMoose.git diff --git a/lib/Moose/Object.pm b/lib/Moose/Object.pm index 6835bd2..2117e0e 100644 --- a/lib/Moose/Object.pm +++ b/lib/Moose/Object.pm @@ -3,13 +3,35 @@ package Moose::Object; use strict; use warnings; -use metaclass; +use metaclass 'Moose::Meta::Class' => ( + ':attribute_metaclass' => 'Moose::Meta::Attribute' +); + +our $VERSION = '0.02'; sub new { - my $class = shift; - $class->meta->new_object(@_); + my ($class, %params) = @_; + my $self = $class->meta->new_object(%params); + $self->BUILDALL(%params); + return $self; +} + +sub BUILDALL { + my ($self, %params) = @_; + foreach my $method ($self->meta->find_all_methods_by_name('BUILD')) { + $method->{code}->($self, %params); + } +} + +sub DEMOLISHALL { + my $self = shift; + foreach my $method ($self->meta->find_all_methods_by_name('DEMOLISH')) { + $method->{code}->($self); + } } +sub DESTROY { goto &DEMOLISHALL } + 1; __END__ @@ -18,9 +40,9 @@ __END__ =head1 NAME -Moose::Object - +Moose::Object - The base object for Moose -=head1 SYNOPSIS +=head1 SYNOPSIS =head1 DESCRIPTION @@ -32,6 +54,18 @@ Moose::Object - =item B +This will create a new instance and call C. + +=item B + +This will call every C method in the inheritance hierarchy. + +=item B + +This will call every C method in the inheritance hierarchy. + +=item B + =back =head1 BUGS @@ -40,13 +74,6 @@ All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. -=head1 CODE COVERAGE - -I use L to test the code coverage of my tests, below is the -L report on this module's test suite. - -=head1 ACKNOWLEDGEMENTS - =head1 AUTHOR Stevan Little Estevan@iinteractive.comE