X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst.pm;h=0f7cd81c76522f073579be92c67f8a85d17a2cd5;hp=ac8b853f4ba338e4403b422de8b7275fd9810543;hb=872323814592a19623a6c72a348ed954659c291f;hpb=5b2a599c524b51bc64bc3f3ff22297e6fa86f441 diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index ac8b853..0f7cd81 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -171,9 +171,7 @@ sub import { . "Please update your scripts by regenerating the " . "application and copying over the new scripts." ) if ( $ENV{CATALYST_SCRIPT_GEN} - && ( - $ENV{CATALYST_SCRIPT_GEN} < $CATALYST_SCRIPT_GEN ) - ); + && ( $ENV{CATALYST_SCRIPT_GEN} < $CATALYST_SCRIPT_GEN ) ); # Process options my @plugins; @@ -258,15 +256,37 @@ C object. To use your own log class: Your log class should implement the methods described in the C man page. +=item $c->plugin( $name, $class, @args ) + +Instant plugins for Catalyst. +Classdata accessor/mutator will be created, class loaded and instantiated. + + MyApp->plugin( 'prototype', 'HTML::Prototype' ); + + $c->prototype->define_javascript_functions; + +=cut + +sub plugin { + my ( $class, $name, $plugin, @args ) = @_; + $plugin->require; + my $error = $UNIVERSAL::require::ERROR; + die qq/Couldn't load instant plugin "$plugin", "$error"/ if $error; + eval { $plugin->import }; + $class->mk_classdata($name); + my $obj; + eval { $obj = $plugin->new(@args) }; + die qq/Couldn't instantiate instant plugin "$plugin", "$@"/ if $@; + $class->$name($obj); + $class->log->debug(qq/Initialized instant plugin "$plugin" as "$name"/) + if $class->debug; +} =back =head1 LIMITATIONS -FCGI and mod_perl2 support are considered experimental and may contain bugs. - -You may encounter problems accessing the built in test server on public ip -addresses on the internet, thats because of a bug in HTTP::Daemon. +mod_perl2 support are considered experimental and may contain bugs. =head1 SUPPORT