Switch everything to autoclean. Add sanity tests to ensure appropriate modern perl...
[catagits/CatalystX-DynamicComponent.git] / lib / CatalystX / DynamicComponent.pm
1 package CatalystX::DynamicComponent;
2 use Moose::Role;
3 use namespace::autoclean;
4
5 sub _setup_dynamic_component {
6     my ($app, $name, $config, $component_method) = @_;
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
16     $meta->add_method( COMPONENT => $component_method );
17
18     $meta->make_immutable;
19
20     my $instance = $app->setup_component($name);
21     $app->components->{ $name } = $instance;
22 }
23
24 1;
25