| 1 |
NAME |
| 2 |
|
| 3 |
Object::Pad::FieldAttr::Trigger - invoke an instance method after a |
| 4 |
:writer accessor |
| 5 |
|
| 6 |
SYNOPSIS |
| 7 |
|
| 8 |
use Object::Pad; |
| 9 |
use Object::Pad::FieldAttr::Trigger; |
| 10 |
|
| 11 |
class Label { |
| 12 |
field $title :param :reader :writer :Trigger(redraw); |
| 13 |
|
| 14 |
method redraw { |
| 15 |
... |
| 16 |
} |
| 17 |
} |
| 18 |
|
| 19 |
my $label = Label->new( text => "Something" ); |
| 20 |
|
| 21 |
$label->set_label( "New text here" ); |
| 22 |
# $label->redraw is automatically invoked |
| 23 |
|
| 24 |
DESCRIPTION |
| 25 |
|
| 26 |
This module provides a third-party field attribute for |
| 27 |
Object::Pad-based classes, which declares that a named instance method |
| 28 |
shall be invoked after a generated :writer accessor method is called. |
| 29 |
|
| 30 |
WARNING The ability for Object::Pad to take third-party field |
| 31 |
attributes is still new and highly experimental, and subject to much |
| 32 |
API change in future. As a result, this module should be considered |
| 33 |
equally experimental. |
| 34 |
|
| 35 |
FIELD ATTRIBUTES |
| 36 |
|
| 37 |
:Trigger |
| 38 |
|
| 39 |
field $name :writer :Trigger(NAME) ...; |
| 40 |
|
| 41 |
Declares that the accessor method generated for the field by the |
| 42 |
:writer attribute will invoke the method named by the :Trigger |
| 43 |
attribute, after the new value has been stored into the field itself. |
| 44 |
This method is invoked with no additional arguments, in void context. |
| 45 |
|
| 46 |
Note that this only applies to the generated accessor method. It does |
| 47 |
not apply to direct modifications of the field variable by method code |
| 48 |
within the class itself. |
| 49 |
|
| 50 |
AUTHOR |
| 51 |
|
| 52 |
Paul Evans <[email protected]> |
| 53 |
|