[Rt-commit] rt branch, update-action, updated. 7d9e04938c068f47b667a498d6062caaabd421e5
sartak at bestpractical.com
sartak at bestpractical.com
Thu Dec 10 03:43:09 EST 2009
The branch, update-action has been updated
via 7d9e04938c068f47b667a498d6062caaabd421e5 (commit)
from 1bc971ac9a846a35b83a312475bfd7013fda1ee8 (commit)
Summary of changes:
lib/RT/Action/TicketAction.pm | 29 ++++++++++++-----------------
1 files changed, 12 insertions(+), 17 deletions(-)
- Log -----------------------------------------------------------------
commit 7d9e04938c068f47b667a498d6062caaabd421e5
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Thu Dec 10 03:42:05 2009 -0500
Unconfuse the shared_canonicalizer logic by just using a coderef
diff --git a/lib/RT/Action/TicketAction.pm b/lib/RT/Action/TicketAction.pm
index 3ee16f3..9f72e2b 100644
--- a/lib/RT/Action/TicketAction.pm
+++ b/lib/RT/Action/TicketAction.pm
@@ -163,33 +163,19 @@ sub _add_parameter_type {
));
};
- if (my $shared_canonicalizer = $args{shared_canonicalizer}) {
- $shared_canonicalizer = "_canonicalize_$name"
- if $shared_canonicalizer eq '1';
-
+ if (my $canonicalizer = $args{canonicalizer}) {
unless ($class->can("canonicalize_$name")) {
*{$class."::canonicalize_$name"} = sub {
use strict 'refs';
my $self = shift;
my $value = shift;
- return $self->$shared_canonicalizer($value, @_);
+ return $self->$canonicalizer($value, @_);
};
}
}
}
-sub _canonicalize_duration {
- my $self = shift;
- my $value = shift;
-
- if (defined $value) {
- $value = parse_duration($value);
- }
-
- return $value;
-}
-
__PACKAGE__->_add_parameter_type(
name => 'ticket_custom_field',
);
@@ -204,7 +190,16 @@ __PACKAGE__->_add_parameter_type(
render_as => 'text', # ideally would be Duration
display_length => 3,
},
- shared_canonicalizer => 1,
+ canonicalizer => sub {
+ my $self = shift;
+ my $value = shift;
+
+ if (defined $value) {
+ $value = parse_duration($value);
+ }
+
+ return $value;
+ },
);
__PACKAGE__->_add_parameter_type(
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list