diff options
author | edenc <edenc@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7> | 2008-09-09 18:49:06 +0000 |
---|---|---|
committer | edenc <edenc@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7> | 2008-09-09 18:49:06 +0000 |
commit | 28a7e0a73bb07c002464d6aabfc54c91339b00d1 (patch) | |
tree | 4d803c37bfe4d2af9184602abf2709436557bf4a /lib/Reaction/UI/ViewPort/Field | |
parent | 7224c229e8bfc9ba5e2a34662ee91ad540bba37c (diff) | |
download | reaction-28a7e0a73bb07c002464d6aabfc54c91339b00d1.tar.gz reaction-28a7e0a73bb07c002464d6aabfc54c91339b00d1.zip |
fixed field sync logic + comments
Diffstat (limited to 'lib/Reaction/UI/ViewPort/Field')
-rw-r--r-- | lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm b/lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm index b2d611d..06e7e72 100644 --- a/lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm +++ b/lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm @@ -30,9 +30,13 @@ sub adopt_value { $self->needs_sync(1); # if $self->has_attribute; } + sub can_sync_to_action { my $self = shift; - return unless $self->needs_sync; + + # if field is already sync'ed, it can be sync'ed again + # this will make sync_to_action no-op if needs_sync is 0 + return 1 unless $self->needs_sync; my $attr = $self->attribute; if ($self->has_value) { @@ -49,8 +53,16 @@ sub can_sync_to_action { } return 1; }; + + sub sync_to_action { my ($self) = @_; + + # don't sync if we're already synced + return unless $self->needs_sync; + + # if we got here, needs_sync is 1 + # can_sync_to_action will do coercion checks, etc. return unless $self->can_sync_to_action; my $attr = $self->attribute; |