This can't work and won't work until generated components do a role. I need that... app_browsing_and_introspection mirror/app_browsing_and_introspection
t0m [Fri, 24 Apr 2009 22:03:39 +0000 (23:03 +0100)]
lib/CatalystX/DynamicControllerIntrospection.pm [new file with mode: 0644]
lib/DynamicAppDemo/Controller/Browser.pm [new file with mode: 0644]

diff --git a/lib/CatalystX/DynamicControllerIntrospection.pm b/lib/CatalystX/DynamicControllerIntrospection.pm
new file mode 100644 (file)
index 0000000..723bc5a
--- /dev/null
@@ -0,0 +1,23 @@
+package CatalystX::Dynamic::ControllerIntrospection;
+use Moose;
+use MooseX::Types::Moose qw/ArrayRef/;
+use namespace::autoclean;
+
+# SYNOPSIS: Provide catalyst controller introspection as a model.
+
+for my $name (qw/ classes roles /) {
+
+    has "limit_to_$name" => ( 
+        isa => ArrayRef, is => 'ro', default => sub { [] }, 
+        predicate => "_should_limit_to_$name",
+    );
+
+}
+
+sub list_controllers {
+    my ($self, $app) = @_;
+    my @controllers = grep { 1 } $app->controllers;
+}
+
+__PACKAGE__->meta->make_immutable;
+
diff --git a/lib/DynamicAppDemo/Controller/Browser.pm b/lib/DynamicAppDemo/Controller/Browser.pm
new file mode 100644 (file)
index 0000000..ededd4c
--- /dev/null
@@ -0,0 +1,17 @@
+package DynamicAppDemo::Controller::Browser;
+use Moose;
+use namespace::autoclean;
+
+BEGIN { extends 'Catalyst::Controller'; }
+
+sub root : Chained('/root') PathPart('') CaptureArgs() {}
+
+sub list : Chained('root') PathPart('') Args(0) ActionClass('REST') {}
+
+sub list_GET {
+    my ($self, $c) = @_;
+    $c->stash->{rest} = $c->model('DynamicControllerIntrospection')->list_controllers;
+}
+
+__PACKAGE__->meta->make_immutable;
+