X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FManual%2FExtendingCatalyst.pod;h=824dafc130a48107877ef9f06d89d4558fcffaf7;hb=614b484ca966389470528db752d8e73a1ac6ebdc;hp=2e497f14390d96e51a9e67adf09ec7d0f7dcdaa8;hpb=fa025310d03b9a7c3da9368c6cd7aec3ced82820;p=catagits%2FCatalyst-Manual.git diff --git a/lib/Catalyst/Manual/ExtendingCatalyst.pod b/lib/Catalyst/Manual/ExtendingCatalyst.pod index 2e497f1..824dafc 100644 --- a/lib/Catalyst/Manual/ExtendingCatalyst.pod +++ b/lib/Catalyst/Manual/ExtendingCatalyst.pod @@ -119,11 +119,15 @@ via multiple inheritence, if your functionality is well structured, then it's possible to use the composability of L roles, and method modifiers to hook onto to provide functionality. -For a simple example of this, see L. +These can be applied to your models/views/controllers, and your application +class, and shipped to CPAN. +Please see L for specific information +about using Roles in combination with Catalyst, and L +for more information about roles in general. =head2 Inheritance and overriding methods -When overriding a method, keep in mind that some day additionally +When overriding a method, keep in mind that some day additionall arguments may be provided to the method, if the last parameter is not a flat list. It is thus better to override a method by shifting the invocant off of C<@_> and assign the rest of the used arguments, so @@ -593,7 +597,7 @@ A simple example like this is actually better as a L role, for example: package CatalystX::UriforUndefWarning; use Moose::Role; - use namespace::clean -except => 'meta'; + use namespace::autoclean; after 'uri_for' => sub { my ($c, $arg) = @_; @@ -626,12 +630,15 @@ Here is a stub C method: sub COMPONENT { my $class = shift; - my ($app_class, $config) = @_; - - # do things here before instantiation my - $obj = $self->next::method(@_); - # do things to object after instantiation - return $object; + # Note: $app is like $c, but since the application isn't fully + # initialized, we don't want to call it $c yet. $config + # is a hashref of config options possibly set on this component. + my ($app, $config) = @_; + + # Do things here before instantiation + $new = $class->next::method(@_); + # Do things to object after instantiation + return $new; } The arguments are the class name of the component, the class name of