Commit | Line | Data |
59fc9d16 |
1 | package CatalystX::DynamicComponent; |
2 | use Moose::Role; |
046d763d |
3 | use namespace::autoclean; |
59fc9d16 |
4 | |
5 | sub _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 | |
24 | 1; |
25 | |