Changeset 2178

Show
Ignore:
Timestamp:
03/03/07 18:26:18
Author:
jesse
Message:

r52909@152: jesse | 2007-03-03 01:15:57 +0000

  • synced README with lib
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Class-Trigger/branches/return-values/README

    r413 r2178  
    99          my $self = shift; 
    1010          $self->call_trigger('before_foo'); 
    11           $self->do_foo; 
     11          # some code ... 
     12          $self->call_trigger('middle_of_foo'); 
     13          # some code ... 
    1214          $self->call_trigger('after_foo'); 
    1315      } 
     
    1820 
    1921      my $foo = Foo->new; 
    20       $foo->foo;                    # then sub1, sub2 called 
     22      $foo->foo;            # then sub1, sub2 called 
    2123 
    2224      # triggers are inheritable 
     
    2729 
    2830      # triggers can be object based 
    29       $foo->add_hook(after_foo => \&sub3); 
    30       $foo->foo;                    # sub3 would appply only to this object 
     31      $foo->add_trigger(after_foo => \&sub3); 
     32      $foo->foo;            # sub3 would appply only to this object 
    3133 
    3234DESCRIPTION 
     
    4143          $foo->add_trigger($triggerpoint => $sub); 
    4244 
     45          Foo->add_trigger( name => $triggerpoint, 
     46                            callback => sub {return undef}, 
     47                            abortable => 1);  
     48 
     49          # no further triggers will be called. Undef will be returned. 
     50 
    4351        Adds triggers for trigger point. You can have any number of triggers 
    44         for each point. Each coderef will be passed a copy of the object, 
    45         and return values will be ignored
     52        for each point. Each coderef will be passed a reference to the 
     53        calling object, as well as arguments passed in via run_trigger
    4654 
    47         If "add_trigger" is called as object method, whole trigger table 
    48         will be copied onto the object. Then the object should be 
    49         implemented as hash. 
     55        If add_trigger is called with named_parameters and the "abortable" 
     56        parameter is passed a true value, a false return values will stop 
     57        processing of this trigger point. If the trigger is "abortable" 
     58        return the return value from the last callback processed will be 
     59        returned to calling code. 
     60 
     61        If "add_trigger" is called without the "abortable" flag, return 
     62        values will be ignored. 
     63 
     64        If "add_trigger" is called as object method, whole current trigger 
     65        table will be copied onto the object and the new trigger added to 
     66        that. (The object must be implemented as hash.) 
    5067 
    5168          my $foo = Foo->new; 
     
    6077 
    6178    call_trigger 
    62           $foo->call_trigger($triggerpoint); 
     79          $foo->call_trigger($triggerpoint, @args); 
    6380 
    6481        Calls triggers for trigger point, which were added via "add_trigger" 
    65         method. Each triggers will be passed a copy of the object. 
     82        method. Each triggers will be passed a copy of the object as the 
     83        first argument. Remaining arguments passed to "call_trigger" will be 
     84        passed on to each trigger. Triggers are invoked in the same order 
     85        they were defined. 
    6686 
    6787TRIGGER POINTS 
     
    118138        that row, and on DELETE to remove that index row. 
    119139 
    120         See the Class::DBI::mysql::FullTextSearch manpage and its source 
    121         code to see it in action. 
     140        See Class::DBI::mysql::FullTextSearch and its source code to see it 
     141        in action. 
    122142 
    123143AUTHOR 
     
    130150 
    131151SEE ALSO 
    132     the Class::Data::Inheritable manpage 
     152    Class::DBI 
    133153