Switch everything to autoclean. Add sanity tests to ensure appropriate modern perl...
[catagits/CatalystX-DynamicComponent.git] / lib / CatalystX / DynamicComponent.pm
CommitLineData
59fc9d16 1package CatalystX::DynamicComponent;
2use Moose::Role;
046d763d 3use namespace::autoclean;
59fc9d16 4
5sub _setup_dynamic_component {
77e54b00 6 my ($app, $name, $config, $component_method) = @_;
59fc9d16 7
8 my $appclass = blessed($app) || $app;
9 my $type = $name;
10 $type =~ s/^${appclass}:://; # FIXME - I think there is shit in C::Utils to do this.
11 $type =~ s/::.*$//;
12
13 my $meta = Moose->init_meta( for_class => $name );
14 $meta->superclasses('Catalyst::' . $type);
15
77e54b00 16 $meta->add_method( COMPONENT => $component_method );
59fc9d16 17
18 $meta->make_immutable;
19
20 my $instance = $app->setup_component($name);
21 $app->components->{ $name } = $instance;
22}
23
241;
25