$VERSION = eval $VERSION;
has class => (
- is => 'rw', required => 1,
+ is => 'rw', lazy => 1, builder => 1,
trigger => sub { shift->_clear_final_class },
);
+sub _build_class { die "No default class set" }
+
has roles => (
- is => 'rw', builder => 1,
+ is => 'rw', lazy => 1, builder => 1,
trigger => sub { shift->_clear_final_class },
clearer => 'reset_roles',
);
+after reset_roles => sub { shift->_clear_final_class };
+
sub _build_roles { [] }
has _final_class => (is => 'lazy', clearer => 1);
clearer => 'reset_arguments',
);
+after reset_arguments => sub { shift->_clear_final_arguments };
+
sub _build_arguments { {} }
has argument_filter => (
$self->_final_class->${\$self->constructor}($self->_final_arguments);
}
+sub BUILD {
+ my ($self, $args) = @_;
+ unless (
+ $args->{object} or $args->{class}
+ or ($self->can('_build_class') ne __PACKAGE__->can('_build_class')
+ ) {
+ die "No static object passed, and no class supplied or defaulted";
+ }
+}
+
1;
=head1 NAME