# this provides a hook to allow subclasses, roles, traits etc a chance to change
# how the class will behave
- my $built_class = $real_class->BUILDALLCLASS($params);
+ my $built_class = $real_class->BUILDCLASS($params);
+ # type safety check
+ unless ( $built_class->isa($real_class) ) {
+ Class::MOP::class_of($class)->throw_error("BUILDCLASS returned a class not derrived from $class");
+ }
my $self = Class::MOP::Class->initialize($built_class)->new_object($params);
$self->BUILDALL($params);
}
-sub BUILDALLCLASS {
- # NOTE: we ask Perl if we even
- # need to do this first, to avoid
- # extra meta level calls
- return $_[0] unless $_[0]->can('BUILDCLASS');
- my ($class, $params) = @_;
- foreach my $method (reverse Class::MOP::class_of($class)->find_all_methods_by_name('BUILDCLASS')) {
- $class = $method->{code}->execute($class, $params);
- }
- return $class;
+sub BUILDCLASS {
+ # real simple, just here to provide a hook
+ shift;
}
sub DEMOLISHALL {