Changeset 12991

Show
Ignore:
Timestamp:
06/01/08 20:27:26 (6 months ago)
Author:
tokuhirom
Message:

added docs.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/MooseX-Plaggerize/trunk/lib/MooseX/Plaggerize.pm

    r12909 r12991  
    5555sub run_hook_first { 
    5656    my ( $self, $point, @args ) = @_; 
     57    croak 'missing hook point' unless $point; 
     58 
    5759    for my $hook ( @{ $self->__moosex_plaggerize_hooks->{$point} } ) { 
    58         if ( my $res = $hook->{code}->( $hook->{plugin}, @args ) ) { 
     60        if ( my $res = $hook->{code}->( $hook->{plugin}, $self, @args ) ) { 
    5961            return $res; 
    6062        } 
     
    6668    my ( $self, $point, @args ) = @_; 
    6769    for my $hook ( @{ $self->__moosex_plaggerize_hooks->{$point} } ) { 
    68         @args = $hook->{code}->( $hook->{plugin}, @args ); 
     70        @args = $hook->{code}->( $hook->{plugin}, $self, @args ); 
    6971    } 
    7072    return @args; 
     
    128130MooseX::Plaggerize is Plagger like plugin system for Moose. 
    129131 
     132MooseX::Plaggerize is a Moose::Role.You can use this module with 'with'. 
     133 
     134=head1 METHOD 
     135 
     136=over 4 
     137 
     138=item $self->load_plugin({ module => $module, config => $conf) 
     139 
     140if you write: 
     141 
     142    my $app = MyApp->new; 
     143    $app->load_plugin({ module => 'Foo', config => {hoge => 'fuga'}) 
     144 
     145above code executes follow code: 
     146 
     147    my $app = MyApp->new; 
     148    my $plugin = MyApp::Plugin::Foo->new({hoge => 'fuga'}); 
     149    $plugin->register( $app ); 
     150 
     151=item $self->register_hook('hook point', $plugin, $code) 
     152 
     153register code to hook point.$plugin is instance of plugin. 
     154 
     155=item $self->run_hook('finalize', $c) 
     156 
     157run hook. 
     158 
     159use case: mostly ;-) 
     160 
     161=item $self->run_hook_first('hook point', @args) 
     162 
     163run hook. 
     164 
     165if your hook code returns true value, stop the hook loop(this feature likes OK/DECLINED of mod_perl handler). 
     166 
     167(please look source code :) 
     168 
     169use case: handler like mod_perl 
     170 
     171=item $self->run_hook_filter('hook point', @args) 
     172 
     173run hook. 
     174 
     175(please look source code :) 
     176 
     177use case: html filter 
     178 
     179=item $self->get_hook('hook point') 
     180 
     181get the codes. 
     182 
     183use case: write tricky code :-( 
     184 
     185=back 
     186 
    130187=head1 TODO 
    131188